tresinformal / drakkar

The tresinformal video game called 'Drakkar'
GNU General Public License v3.0
11 stars 4 forks source link

Implement << operator for the player_state class #509

Closed janclod closed 2 years ago

janclod commented 2 years ago

The class player_state does not have an << operator yet.

Please add one, start by adding this test to the player_state.cpp file inside the test_player_state() function.

  // operator<<
  {
    std::stringstream s;
    const player_state ps = player_state::active;
    s << ps;
  }
  {
    const player_state ps = player_state::active;
    std::cout << ps;
  }

You can get inspired on how to implement the operator from class sound_type sound_type.h

/// implement << operator
std::ostream& operator << (std::ostream& os, const sound_type& sound);

sound_type.cpp

std::ostream& operator << (std::ostream& os, const sound_type& sound)
{
    os << to_str(sound);
    return os;
}