diff options
Diffstat (limited to 'Bachelor/Prog2/Prakt3/Aufg1/Table.cpp')
| -rw-r--r-- | Bachelor/Prog2/Prakt3/Aufg1/Table.cpp | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/Bachelor/Prog2/Prakt3/Aufg1/Table.cpp b/Bachelor/Prog2/Prakt3/Aufg1/Table.cpp new file mode 100644 index 0000000..9b6a2bf --- /dev/null +++ b/Bachelor/Prog2/Prakt3/Aufg1/Table.cpp @@ -0,0 +1,52 @@ +#include "Table.h"
+#include "Team.h"
+#include <iostream>
+#include <iomanip>
+
+using std::cout;
+using std::endl;
+using std::string;
+using std::ostream;
+using std::left;
+using std::setw;
+
+void Table::setTeam(const Team& toSet)
+{
+ teams.push_back(toSet);
+}
+
+void Table::print(ostream& output)
+{
+ int n=0;
+ output << left << setw(22) << "Team" << setw(9) << "Matches" << setw(12) << "Games won" << setw(12)
+ << "Games lost" << setw(12) << "Points won" << setw(12) << "Points lost" << endl;;
+
+ while(n<teams.size())
+ {
+ output << left << setw(22) << teams[n].getTeamName() << setw(9) << teams[n].getmatchesPlayed() << setw(12) << teams[n].getgamesWon()
+ << setw(12) << teams[n].getgamesLost() << setw(12) << teams[n].getpointsWon() << setw(12) << teams[n].getpointsLost() <<endl;
+ n++;
+ }
+}
+
+void Table::sort()
+{
+ Team temp;
+ int n;
+ for (n=0;n<teams.size();n++)
+ {
+ // start from actual position...
+ for (int j=n;j<teams.size();j++)
+ {
+ // ... search the maximum...
+ //if(teams[j].getpointsWon()>teams[n].getpointsWon())
+ if(!(teams[j]<teams[n]))
+ {
+ //... and insert it
+ temp=teams[n];
+ teams[n]=teams[j];
+ teams[j]=temp;
+ }
+ }
+ }
+}
|
