diff options
| author | Sven Eisenhauer <sven@sven-eisenhauer.net> | 2023-11-10 15:11:48 +0100 |
|---|---|---|
| committer | Sven Eisenhauer <sven@sven-eisenhauer.net> | 2023-11-10 15:11:48 +0100 |
| commit | 33613a85afc4b1481367fbe92a17ee59c240250b (patch) | |
| tree | 670b842326116b376b505ec2263878912fca97e2 /Bachelor/Prog2/Prakt3/Aufg1/Team.cpp | |
| download | Studium-master.tar.gz Studium-master.tar.bz2 | |
Diffstat (limited to 'Bachelor/Prog2/Prakt3/Aufg1/Team.cpp')
| -rw-r--r-- | Bachelor/Prog2/Prakt3/Aufg1/Team.cpp | 116 |
1 files changed, 116 insertions, 0 deletions
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 <iostream>
+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 <char*> (&matchesPlayed), 5 * sizeof( int ) );
+ return input;
+}
|
