예제 #1
0
car2.setMake('Toyota')
car2.setModel('Yaris')
car2.setColour('Green')
car2.setMileage(653)
car2.setNumberCylinders(4)
print 'Petrol car type: ' + car2.getMake()
print 'Model: ' + car2.getModel()
print 'Colour: ' + car2.getColour()
print 'Number of cylinders: ' + str(car2.getNumberCylinders())
print 'Mileage on the clock: ' + str(car2.getMileage())
print '------------------'

# Diesel car
car3 = DieselCar()
car3.setMake('Ford')
car3.setModel('Mondeo')
car3.setColour('Black')
car3.setMileage(2500)
car3.setNumberDieselCylinders(6)
print 'Diesel car type: ' + car3.getMake()
print 'Model: ' + car3.getModel()
print 'Colour: ' + car3.getColour()
print 'Number of cylinders: ' + str(car3.getNumberDieselCylinders())
print 'Mileage on the clock: ' + str(car3.getMileage())
print '------------------'

# Hybrid car
car4 = HybridCar()
car4.setMake('Ford')
car4.setModel('Fusion Hybrid')
car4.setColour('Blue')
예제 #2
0
파일: carApp.py 프로젝트: lulu0066/B8IT105
from car import Car, PetrolCar, DieselCar, ElectricCar, HybridCar
from carRental import CarFleet

dbsCarRental = CarFleet()
myCar = Car()

myCar.setColour('Silver')

petrol = PetrolCar()
petrol.setMake('Ford')
petrol.setModel('Focus')
petrol.setEngineSize('1.6')

diesel = DieselCar()
diesel.setMake('Renault')
diesel.setModel('Clio')
diesel.setEngineSize('1.5')

electric = ElectricCar()
electric.setMake('Nissan')
electric.setModel('Leaf')
electric.setNumberFuelCells('62KWH')

hybrid = HybridCar()
hybrid.setMake('Toyota')
hybrid.setModel('Corolla')


# the initial stock of cars
def initial_cars_stock_csv(csv_file):
    type = ['Petrol', 'Diesel', 'Electric', 'Hybrid']