From 33613a85afc4b1481367fbe92a17ee59c240250b Mon Sep 17 00:00:00 2001 From: Sven Eisenhauer Date: Fri, 10 Nov 2023 15:11:48 +0100 Subject: add new repo --- Bachelor/Prog2/Prakt3/Aufg1/Team.cpp | 116 +++++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) create mode 100644 Bachelor/Prog2/Prakt3/Aufg1/Team.cpp (limited to 'Bachelor/Prog2/Prakt3/Aufg1/Team.cpp') diff --git a/Bachelor/Prog2/Prakt3/Aufg1/Team.cpp b/Bachelor/Prog2/Prakt3/Aufg1/Team.cpp new file mode 100644 index 0000000..86b1a95 --- /dev/null +++ b/Bachelor/Prog2/Prakt3/Aufg1/Team.cpp @@ -0,0 +1,116 @@ +#include "Team.h" +#include +using std::istream; +using std::getline; + +Team::Team() +{ +} + +Team::~Team() +{ +} + +void Team::setTeamName(const string& name) +{ + teamName=name; +} + +const string& Team::getTeamName() const +{ + return teamName; +} + +void Team::setmatchesPlayed(int matchesp) +{ + matchesPlayed=matchesp; +} + +const int Team::getmatchesPlayed() const +{ + return matchesPlayed; +} + +void Team::setgamesWon(int gw) +{ + gamesWon=gw; +} + +const int Team::getgamesWon() const +{ + return gamesWon; +} + +void Team::setgamesLost(int gl) +{ + gamesLost=gl; +} + +const int Team::getgamesLost() const +{ + return gamesLost; +} + +void Team::setpointsWon(int pw) +{ + pointsWon=pw; +} + +const int Team::getpointsWon() const +{ + return pointsWon; +} + +void Team::setpointsLost(int pl) +{ + pointsLost=pl; +} + +const int Team::getpointsLost() const +{ + return pointsLost; +} + +const Team& Team::operator=(const Team& toCopy) +{ + setTeamName(toCopy.getTeamName()); + setgamesWon(toCopy.getgamesWon()); + setgamesLost(toCopy.getgamesLost()); + setpointsWon(toCopy.getpointsWon()); + setpointsLost(toCopy.getpointsLost()); + setmatchesPlayed(toCopy.getmatchesPlayed()); + + return *this; +} + +bool Team::operator<(const Team& toComp) +{ + if (getpointsWon() < toComp.getpointsWon()) + return true; + else + { + if (getpointsWon() == toComp.getpointsWon()) + { + if (getpointsLost() < toComp.getpointsLost()) + return true; + if (getpointsLost() == toComp.getpointsLost()) + { + if ( (getgamesWon()-getgamesLost()) < (toComp.getgamesWon()-toComp.getgamesLost())) + return true; + } + } + + return false; + } +} + +istream& Team::read(istream& input) +{ + + + string test; + getline( input, test, '\0' ); + this->setTeamName(test); + input.read( reinterpret_cast (&matchesPlayed), 5 * sizeof( int ) ); + return input; +} -- cgit v1.2.3