-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsquare.py
47 lines (31 loc) · 902 Bytes
/
square.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
class Rectangle:
def __init__(self ,height="0",width="0"):
self.height=height
self.width=width
##getter and setters
@property
def height(self):
return self.__height
@height.setter
def height(self ,value):
if value.isdigit():
self.__height= value
@property
def width(self):
return self.__width
@width.setter
def width(self, value):
if value.isdigit():
self.__width = value
def getArea(self):
return (int(self.__height)*int(self.__width))
def main():
arect= Rectangle()
height = input("enter the height of the rectangle")
width =input("enter the width of the rectangle")
arect.height=height
arect.width=width
print("height entered is", arect.height)
print("widht entered is",arect.width)
print("the area is",arect.getArea())
main()