-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCar.py
More file actions
39 lines (28 loc) · 817 Bytes
/
Car.py
File metadata and controls
39 lines (28 loc) · 817 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
class Car(object):
"""This class will create a new car"""
make = ""
model = ""
year = 0
def __init__(self, make=None, model=None, year=None):
if make != None:
self.make = make
else:
self.make = "generic make"
if model != None:
self.model = model
else:
self.model = "generic model"
if self.year != None:
self.year = year
else:
self.year = 1900
def printDetails(self):
print self.make + " " + self.model + " " + str(self.year)
new_car = Car()
new_car.printDetails()
new_car2 = Car("Toyota")
new_car2.printDetails()
new_car3 = Car("Honda", "Civic")
new_car3.printDetails()
new_car3 = Car("Porsche", "Civic", 2015)
new_car3.printDetails()