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
/
Copy pathClient.py
163 lines (140 loc) · 4.65 KB
/
Client.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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# 2018-2019 Programação 2 (LTI)
# Grupo 34
# 49269 Mário Gil Oliveira
# 46261 Margarida Rolo
class Client:
def __init__(self, name, zone, dateTime, max_hourly_charge, min_rating, required_expertise, duration):
"""
Initializes a Client object
Requires: name, zone as str
Requires: required_expertise as tuple
Requires: min_rating as int between 0 and 5
Requires: max_hourly_charge, duration as float
"""
self._name = name
self._zone = zone
self._dateTime = dateTime
self._max_hourly_charge = max_hourly_charge
self._min_rating = min_rating
self._required_expertise = required_expertise
self._duration = duration
def getName(self):
"""
Returns the name of the client.
Ensures: a str with the client's name.
"""
return self._name
def getZone(self):
"""
Returns the zone of the client.
Ensures: a str with the name of the zone.
"""
return self._zone
def getDateTime(self):
"""
"""
return self._dateTime
def getMax_hourly_charge(self):
"""
Returns the maximum accepted by the client to be charged per hour.
Ensures: a float of the maximum accepted by the client to be charged per hour.
"""
return self._max_hourly_charge
def getMin_rating(self):
"""
Returns the minimum rating of the expert accepted by the client.
Ensures: an int between 0 and 5, the star rating of the expert.
"""
return self._min_rating
def getRequired_expertise(self):
"""
Returns the expertise needed by the client.
Ensures: a tuple expertise needed for the job.
"""
return self._required_expertise
def getDuration(self):
"""
Returns the duration of the job required by the client.
Ensures: a float with the duration of the job.
"""
return self._duration
def setName(self, name):
"""
Sets the name of the Client.
Requires: name (is str)
"""
self._name = name
def setZone(self, zone):
"""
Sets the zone of the Client.
Requires: zone (is str)
"""
self._zone = zone
def setdateTime(self, dateTime):
"""
Sets the dateTime of the Client.
Requires: dateTime (is dateTime)
"""
self._dateTime = dateTime
def setMax_hourly_charge(self, max_hourly_charge):
"""
Sets the max hourly charge the client accepts.
Requires: max_hourly_charge (is int)
"""
self._max_hourly_charge = max_hourly_charge
def setMin_rating(self, min_rating):
"""
Sets the minimum rating the client accepts.
Requires: min_rating (is int)
"""
self._min_rating = min_rating
def setRequired_expertise(self, required_expertise):
"""
Sets the skill required for the job.
Requires: required_expertise (is str)
"""
self._required_expertise = required_expertise
def setDuration(self, duration):
"""
Sets the duration of the job.
Requires: duration (is duration)
"""
self._duration = duration
def items (self):
"""
Iterates over the various attributes of client.
Name, Zone, DateTime, Max Charge, Max Rating, Required Skill, Duration
"""
for i in [self.getName(),
self.getZone(),
self.getDateTime(),
self.getMax_hourly_charge(),
self.getMin_rating(),
self.getRequired_expertise(),
self.getDuration()]:
yield i
def __str__(self):
"""
Sets the string output with all the attributes.
"""
return str(self.getName()) + ', ' +\
str(self.getZone()) + ', ' +\
str(self.getDateTime()) + ', ' +\
str(self.getMax_hourly_charge()) + ', ' +\
str(self.getMin_rating()) + '*, ' +\
str(self.getRequired_expertise()) + ', ' +\
str(self.getDuration())
def __eq__(self, other):
"""
Compares Client timestamps.
Ensures: A bool, True if self and other have the same dateTime.
"""
if self.getDateTime() == other.getdateTime():
return True
def __lt__ (self, other):
"""
Compares Client timestamps.
Ensures: A bool, True if self's dateTime is before other.
"""
if self.getDateTime() < other.getdateTime():
return True