summaryrefslogtreecommitdiffstats
path: root/Bachelor/Prog2/Prakt3/Aufg1/Team.cpp
blob: 86b1a95d5c92bc08e077a9345452b7fd891ad57e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
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;
}