-
Notifications
You must be signed in to change notification settings - Fork 0
/
rent.py
35 lines (28 loc) · 821 Bytes
/
rent.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
class Rent(object):
def __init__(self):
self.total = 0
self.rents = 0
@property
def total_amount(self):
return self.total
def by_hour(self, qty=1):
#charging $5 per hour
self.total += qty * 5
self.rents += 1
return self
def by_day(self, qty=1):
#charging $20 a day
self.total += qty * 20
self.rents += 1
return self
def by_week(self, qty=1):
#changing $60 a week
self.total += qty * 60
self.rents += 1
return self
def apply_family_promotion(self):
#include 3 to 5 Rentals with a discount of 30% total price
if self.rents in range(3, 6):
self.total -= self.total * 0.3
else:
raise ValueError('Promotion does not apply')