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
/
Expert.py
133 lines (112 loc) · 3.57 KB
/
Expert.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
126
127
128
129
130
131
132
133
# 2018-2019 Programação 2 (LTI)
# Grupo 34
# 49269 Mário Gil Oliveira
# 46261 Margarida Rolo
from DateTime import DateTime
class Expert:
def __init__(self, name, zone, skills, rating, rate, dateTime, earnings):
"""
Initializes an Expert object
Requires: name, zone as str
Requires: skills as tuple
Requires: rating as int between 0 and 5
Requires: rate, earnings as float
Requires: dateTime is DateTime
"""
self._name = name # expert Name
self._zone = zone # working zone
self._skills = skills
self._rating = rating
self._rate = rate
self._dateTime = dateTime
self._earnings = earnings
def getName(self):
"""
Returns the name of the expert.
Ensures: a str with the expert's name.
"""
return self._name
def getZone(self):
"""
Returns the zone of the expert.
Ensures: a str with the name of the zone.
"""
return self._zone
def getSkills(self):
"""
Returns the skills of the expert.
Ensures: a tuple of skills.
"""
return self._skills
def getRating(self):
"""
Returns the zone of the expert.
Ensures: an int between 0 and 5, the star rating of the expert.
"""
return self._rating
def getRate(self):
"""
Returns the hourly rate of the expert.
Ensures: a float with the hourly rate.
"""
return self._rate
def getDateTime(self):
"""
Returns next available working time for the expert.
Ensures: a DateTime with the next available free time.
"""
return self._dateTime
def getEarnings(self):
"""
Returns the total earnings of the experts.
Ensures: a float with the total expert earnings.
"""
return self._earnings
def setEarnings(self, earnings):
"""
Sets the earnings of the expert.
Requires: earnings (int)
"""
self._earnings = earnings
def setDateTime(self, dateTime):
"""
Sets the next available time of the expert.
Requires: dateTime (dateTime)
"""
self._dateTime = dateTime
def addTravelTime(self):
"""
Adds the travel time (60 min.) to the dateTime attribute.
If it exceeds the closing time, it sets 'dateTime' to the
next day at opening time.
"""
dateTime = self.getDateTime()
dateTime.addTime(60)
# If the travel time reaches the next day,
# it just sets it to opening time
if dateTime.getHour() == 8:
dateTime.setMinute(0)
self.setDateTime(dateTime)
def __str__(self):
"""
Overrides the string method.
Ensures: an str, in the format to be outputted to the experts file:
with name, zone, skills, rating, hourly rate and total earnings.
"""
return str(self.getName()) + ', ' +\
str(self.getZone()) + ', ' +\
str(self.getSkills()) + ', ' +\
str(self.getRating()) + '*, ' +\
str(self.getRate()) + ', ' +\
str(self.getDateTime()) + ', ' +\
str(self.getEarnings())
def __eq__(self, other):
"""
Overrides the equals (==) operator
"""
return self.getRating() == other.getRating()
def __lt__(self, other):
"""
Overrides the less than (<) operator
"""
return self.getRating() < other.getRating()