-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclasses_demo.py
More file actions
28 lines (20 loc) · 752 Bytes
/
classes_demo.py
File metadata and controls
28 lines (20 loc) · 752 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
"""
This file demonstrates object oriented programming in Python
"""
# Imports
from oop_demo import personal_car, motorcycle, wheeled_vehicles
# Define an object
the_tesla = personal_car.PersonalCar(name="White Tesla", manufacturer="Tesla", model="Model S", fuel="Electric Power")
# And another
the_benz = personal_car.PersonalCar(name="Black Benz", manufacturer="Diamler AG", model="C180")
# Now the bike
the_bike = motorcycle.Motorcycle(name="Little Moped", manufacturer="Vespa", cc=35)
# See what we have
print("Summary: Car 1")
the_tesla.summary()
print("\nSummary: Car 2")
the_benz.summary()
print("\nSummary: Bike 1")
the_bike.summary()
# Use a function from the base class
print("\nThe name of Car 1 is {}".format(the_tesla.get_name()))