-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobject_oriented.py
More file actions
31 lines (24 loc) · 1.29 KB
/
object_oriented.py
File metadata and controls
31 lines (24 loc) · 1.29 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
# Watto needs a new system for organizing his inventory of podracers.
# Help him do this by implementing an Object Oriented solution according to the following criteria.
# First, he'll need a general Podracer class defined with max_speed, condition (perfect, trashed, repaired) and price attributes.
class Podracer:
def __init__(self, max_speed, condition, price):
self.max_speed = max_speed
self.condition = condition
self.price = price
# Define a repair() method that will update the condition of the podracer to "repaired".
def repair(self):
self.condition = "repaired"
# Define a new class, AnakinsPod that inherits the Podracer class, but also contains a special method called boost that will multiply max_speed by 2.
class AnakinsPod(Podracer):
def __init__(self, max_speed, condition, price):
super.init(max_speed, condition, price)
def boost(self):
self.max_speed *= 2
# Define another class that inherits Podracer and call this one SebulbasPod.
# This class should have a special method called flame_jet that will update the condition of another podracer to "trashed".
class SebulbasPod(Podracer):
def __init__(self, max_speed, condition, price):
super.init(max_speed, condition, price)
def flame_jet(self,other):
other.condition = "trashed"