-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpolygonAreaCalculator.py
More file actions
96 lines (68 loc) · 1.96 KB
/
polygonAreaCalculator.py
File metadata and controls
96 lines (68 loc) · 1.96 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
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
'''
Polygon Area Calculator.
'''
class Rectangle:
def __init__(self):
self.a = 0
self.b = 0
self.c = self.a
self.d = self.b
self.area = 0
self.scope = 0
#funcs
def setCalculation(self):
inp = input('What shape do you want to work with? Rectangle (R), Square (S): ').lower()
if inp == 'r':
shape = Rectangle()
elif inp == 's':
shape = Square()
else:
pass
shape.setAttributes()
shape.calculateScope()
shape.calculateArea()
shape.getA()
def setAttributes(self):
self.a = float(input('Enter a value for a: '))
self.b = float(input('Enter a value for b: '))
def calculateArea(self):
self.area = self.a * self.b
print(f'The rectangle has the area {self.area}')
def calculateScope(self):
self.scope = self.a * 2 + self.b * 2
print(f'The rectangle has the scope {self.scope}')
# getter
def getA(self):
print(f'Side a has a value of: {self.a}. ')
class Square(Rectangle):
def __init__(self):
super().__init__()
# funcs
def setAttributes(self):
self.a = float(input('Enter side length of the square: '))
def calculateArea(self):
self.area = self.a**2
print(f'The square has the area {self.area}')
def calculateScope(self):
self.scope = self.a*4
print(f'The square has the scope {self.scope}')
''' Third Project ---> Probability Calculator'''
''' --------------- END OF PROJECT CLASSES CODE --------------- '''
# functions
def firstProject():
b = Budget()
b.setIncome()
b.setExpenseList()
b.setExpenses()
b.subtractExpenses()
print(b.getIncome())
def secondProject():
r = Rectangle()
r.setCalculation()
def thirdProject():
pass
# main-func
def main():
secondProject()
# calling main
main()