-
Notifications
You must be signed in to change notification settings - Fork 548
Expand file tree
/
Copy path02-challenge-solution.py
More file actions
35 lines (25 loc) · 910 Bytes
/
02-challenge-solution.py
File metadata and controls
35 lines (25 loc) · 910 Bytes
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
class Point:
def __init__(self, x, y):
self.x = x
self.y = y
class Rectangle:
def __init__(self, origin, width, height):
self.origin = origin
self.width = width
self.height = height
def get_area(self):
return self.width * self.height
def print_coordinates(self):
top_right = self.origin.x + self.width
bottom_left = self.origin.y + self.height
print('Starting Point (X)): ' + str(self.origin.x))
print('Starting Point (Y)): ' + str(self.origin.y))
print('End Point X-Axis (Top Right): ' + str(top_right))
print('End Point Y-Axis (Bottom Left): ' + str(bottom_left))
def build_rectangle():
rectangle_origin = Point(50, 100)
rectangle = Rectangle(rectangle_origin, 90, 10)
return rectangle
rectangle = build_rectangle()
print(rectangle.get_area())
rectangle.print_coordinates()