-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3.py
More file actions
46 lines (37 loc) · 1.02 KB
/
3.py
File metadata and controls
46 lines (37 loc) · 1.02 KB
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
class Cage():
def __init__(self, quantity):
self.quantity = quantity
def __str__(self):
return f'{Cage} quantity - {self.quantity}'
def __add__(self, new):
new_quantity = self.quantity + new.quantity
return Cage(new_quantity)
def __sub__(self, new):
res = self.quantity - new.quantity
if res > 0:
return res
else:
print('error pirnt!!!!!!!!')
def __mul__(self, new):
new_quantity = self.quantity * new.quantity
return Cage(new_quantity)
def __truediv__(self, new):
new_quantity = int(self.quantity / new.quantity)
return Cage(new_quantity)
def make_order(self, value):
count = 0
res = ''
for i in range(self.quantity):
res += '*'
count += 1
if count == value:
res += '\n'
count = 0
return res
c1 = Cage(10)
c2 = Cage(2)
c3 = c1 / c2
# print(c3)
c4 = Cage(20)
res = c4.make_order(5)
print(res)