Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys, os
- # Moved the methods to the automobile from car
- class Automobile(object):
- def __init__(self, color):
- self.color = color
- self.model = "Honda"
- # It honks!
- def honk(self):
- print "Bee Beep!"
- # prints out the attributes and their number
- def description(self):
- print vars(self)
- class Motorcycle(Automobile):
- def __init__(self, color):
- Automobile.__init__(self, color)
- self.wheelNum = 2
- self.make = "Ducati?"
- self.topSpeed = 70
- class Car(Automobile):
- def __init__(self, color):
- Automobile.__init__(self, color)
- self.wheelNum = 4
- self.make = "Accord?"
- self.topSpeed = 100
- class SemiTruck(Automobile):
- def __init__(self, color):
- Automobile.__init__(self, color)
- self.wheelNum = 16
- self.make = "Big Rig?"
- self.topSpeed = 60
- #test stuff
- if __name__ == "__main__":
- test1 = Car("Red")
- print test1.color
- print test1.topSpeed
- test1.honk()
- test1.description()
- test2 = Motorcycle("Green")
- print test2.color
- print test2.topSpeed
- test2.honk()
- test2.description()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement