forked from driscollis/python101code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathball.py
More file actions
24 lines (18 loc) · 620 Bytes
/
Copy pathball.py
File metadata and controls
24 lines (18 loc) · 620 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
# ball.py
class Ball:
def __init__(self, color: str, size: float, weight: float,
ball_type: str) -> None:
self.color = color
self.size = size
self.weight = weight
self.ball_type = ball_type
def bounce(self):
if self.ball_type.lower() == 'bowling':
print("Bowling balls can't bounce!")
else:
print(f"The {self.ball_type} ball is bouncing!")
if __name__ == "__main__":
ball_one = Ball('black', 6, 12, 'bowling')
ball_two = Ball('red', 12, 1, 'beach')
ball_one.bounce()
ball_two.bounce()