-
Notifications
You must be signed in to change notification settings - Fork 0
/
buildings.py
57 lines (47 loc) · 1.72 KB
/
buildings.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
class Building:
def __init__(self, siding):
self.__siding = siding
def set_siding(self, siding):
self.__siding = siding
def get_siding(self):
return self.__siding
def __str__(self):
return self.__siding
# Inheritance of Building
class House(Building):
"""Initialize with constructor, inherit Building, and pass a value to siding"""
def __init__(self, rooms):
Building.__init__(self, "Brick")
self.__rooms = rooms
self.__total = 0
"""Getters and Setters"""
def set_rooms(self, rooms):
self.__rooms = rooms
def get_rooms(self):
return self.__rooms
"""Loop through the dict and add the values to get the total"""
def total_square_feet(self):
for k, v in self.__rooms.items():
print("The size of {} is: {}".format(k, v))
self.__total += v
print("The total square feet of your Home is: {} square feet.\n"
.format(self.__total))
# Inheritance of Building
class Commercial(Building):
"""Initialize with constructor, inherit Building, and pass a value to siding"""
def __init__(self, rooms):
Building.__init__(self, 'Stone')
self.__rooms = rooms
self.__total = 0
"""Getters and setters"""
def set_rooms(self, rooms):
self.__rooms = rooms
def get_rooms(self):
return self.__rooms
"""Loop through the dict and add the values to get the total"""
def total_square_feet(self):
for k, v in self.__rooms.items():
print("The size of {} is: {}".format(k, v))
self.__total += v
print("The total square feet of your Commercial building is: {} square feet.\n"
.format(self.__total))