#include "Championship.h" #include #include class SoccerTeam { std::string country; long points = 0; public: explicit SoccerTeam(const std::string& country) : country(country) { } std::ostream& print(std::ostream& out) const { return out << country; } std::ostream& printWithPoints(std::ostream& out) const { return out << std::setfill('.') << std::setw(20) << std::left << country << std::setfill(' ') << ' ' << points; } inline const SoccerTeam& operator+=(long points) { this->points += points; return *this; } inline bool operator<(const SoccerTeam& other) const { return points < other.points; } inline bool operator>(const SoccerTeam& other) const { return points > other.points; } friend inline std::ostream& operator<<(std::ostream& out, const SoccerTeam& team) { return team.print(out); } }; int main() { Championship soccerWorldCup; soccerWorldCup << SoccerTeam("Alemania") << SoccerTeam("Algeria") << SoccerTeam("Argentina") << SoccerTeam("Australia") << SoccerTeam("Belgica") << SoccerTeam("Bosnia") << SoccerTeam("Brasil") << SoccerTeam("Camerun") << SoccerTeam("Chile") << SoccerTeam("Colombia") << SoccerTeam("Corea del Sur") << SoccerTeam("Costa de Marfil") << SoccerTeam("Costa Rica") << SoccerTeam("Croacia") << SoccerTeam("Ecuador") << SoccerTeam("EspaƱa") << SoccerTeam("Estados Unidos") << SoccerTeam("Francia") << SoccerTeam("Ghana") << SoccerTeam("Grecia") << SoccerTeam("Holanda") << SoccerTeam("Honduras") << SoccerTeam("Inglaterra") << SoccerTeam("Iran") << SoccerTeam("Italia") << SoccerTeam("Japon") << SoccerTeam("Mexico") << SoccerTeam("Nigeria") << SoccerTeam("Portugal") << SoccerTeam("Rusia") << SoccerTeam("Suiza") << SoccerTeam("Uruguay"); soccerWorldCup.setGroupCount(8); if ( ! soccerWorldCup.makeGroups() ) return 1; soccerWorldCup.printGroups(std::cout); std::cout << "\n\nMatches:\n"; soccerWorldCup.update(); soccerWorldCup.printMatches(std::cout); for (Championship::MatchIterator itr = soccerWorldCup.beginMatch(); itr != soccerWorldCup.endMatch(); ++itr) (*itr).inventScores(8); std::cout << "\n\nInventing scores:\n"; soccerWorldCup.printMatches(std::cout); std::cout << "\n\nGroups and points:\n"; soccerWorldCup.update(); soccerWorldCup.printGroups(std::cout, true); std::cout << "\n\nMatches:\n"; soccerWorldCup.printMatches(std::cout); return 0; }