summaryrefslogtreecommitdiffstats
path: root/Bachelor/Prog2/Prakt3/Aufg1/Team.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Bachelor/Prog2/Prakt3/Aufg1/Team.cpp')
-rw-r--r--Bachelor/Prog2/Prakt3/Aufg1/Team.cpp116
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;
+}