-
Notifications
You must be signed in to change notification settings - Fork 0
/
vault.py
36 lines (29 loc) · 990 Bytes
/
vault.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
class Vault:
def __init__(self, galleons=0, sickles=0, knuts=0):
self.galleons = galleons
self.sickles = sickles
self.knuts = knuts
def __str__(self):
return f"{self.galleons} Galleons, {self.sickles} Sickles, {self.knuts} Knuts"
def __add__(self, other):
# galleons = self.galleons + other.galleons
# sickles = self.sickles + other.sickles
# knuts = self.knuts + other.knuts
# return Vault(galleons, sickles, knuts)
return Vault(
self.galleons + other.galleons,
self.sickles + other.sickles,
self.knuts + other.knuts
)
potter = Vault(100, 50, 25)
print(potter)
weasley = Vault(25, 50, 100)
print(weasley)
'''
galleons = potter.galleons + weasley.galleons
sickles = potter.sickles + weasley.sickles
knuts = potter.knuts + weasley.knuts
total = Vault(galleons, sickles, knuts)
'''
total = potter + weasley
print(total)