This repository has been archived by the owner on Apr 11, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Match.py
125 lines (99 loc) · 3.09 KB
/
Match.py
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
117
118
119
120
121
122
123
124
125
# 2018-2019 Programação 2 (LTI)
# Grupo 34
# 49269 Mário Gil Oliveira
# 46261 Margarida Rolo
class Match:
def __init__(self, success, client="", expert="", time=""):
"""
Initiates a new Match object. This object saves the
info about a specific schedule item. It saves info
regarding the time of the job, and the people involved.
If success == False, it assumes the request was declined.
Requires: success as bool (False if declined)
Requires: client as Client.
Requires: expert as Expert.
Ensures: The creation of a new object with
two attributes, client and expert.
"""
self._success = success
self._client = client
self._expert = expert
self._time = time
def getClient(self):
"""
Returns the client.
Ensures: client as Client.
"""
return self._client
def getExpert(self):
"""
Returns the expert.
Ensures: expert as Expert.
"""
return self._expert
def setClient(self, client):
"""
Sets the client.
Requires: client is Client
"""
self._client = client
def setExpert(self, expert):
"""
Sets the expert.
Requires: expert is Expert.
"""
self._expert = expert
def setTime(self, time):
"""
Sets the match time.
Requires: time is DateTime
"""
self._time = time
def getTime(self):
"""
Gets the match time as DateTime.
"""
return self._time
def getSuccess(self):
"""
Returns True if match was successful,
False if declined.
"""
return self._success
def setSuccess(self, success):
"""
Sets the success attribute.
Requires: success as bool
"""
self._success = success
def __str__(self):
"""
Returns a string in the format to be written
in the schedule file, if success is False,
it will return the the string to be written in
case of a declined request.
"""
matchDate = self.getTime().getDate()
matchTime = self.getTime().getTime()
clientName = self.getClient().getName()
if self.getSuccess():
expertName = self.getExpert().getName()
return str(matchDate) + ', ' + str(matchTime) + ', ' +\
str(clientName) + ', ' + str(expertName)
else:
return str(matchDate) + ', ' + str(matchTime) + ', ' +\
str(clientName) + ', declined'
def __eq__(self, other):
"""
Compares Match timestamps (==).
Ensures: a Bool, True if the timestamps are the same between self and other.
"""
if self.getTime() == other.getTime():
return True
def __lt__(self, other):
"""
Compares Match timestamps (<).
Ensures: a Bool, True if the timestamps of self comes before other.
"""
if self.getTime() < other.getTime():
return True