def setUp(self):
     self.car = Car()
     self.car1 = ElectricCar(1)
     self.car2 = PetrolCar(2)
     self.car3 = DieselCar(3)
     self.car4 = HybridCar(4)
     self.dealership = Dealership()
     self.dealership.create_current_stock()
示例#2
0
class TestDiesel(unittest.TestCase):
    
    def setUp(self):
        self.diesel = DieselCar()
    
    def test_diesel_engineSize(self):
        self.assertEqual('', self.diesel.getEngineSize())
        self.diesel.setEngineSize('2.5')
        self.assertEqual('2.5', self.diesel.getEngineSize())
class TestCar(unittest.TestCase):
    def setUp(self):
        self.car = Car()
        self.car1 = ElectricCar(1)
        self.car2 = PetrolCar(2)
        self.car3 = DieselCar(3)
        self.car4 = HybridCar(4)
        self.dealership = Dealership()
        self.dealership.create_current_stock()

    def test_car_mileage(self):
        self.assertEqual(0, self.car.getMileage())
        self.car.move(15)  # this function exists for all child classes of car
        self.assertEqual(15, self.car.getMileage())

    def test_car_make(self):
        self.car.setMake(
            'Ferrari')  # this function exists for all child classes of car
        self.assertEqual('Ferrari', self.car.getMake())
        self.assertEqual('Ferrari', self.car.getMake())
        self.assertEqual('Tesla', self.car1.getMake())
        self.assertEqual('Toyota', self.car2.getMake())
        self.assertEqual('Volkswagon', self.car3.getMake())
        self.assertEqual('Mitsubishi', self.car4.getMake())

    def test_car_colour(self):
        self.assertEqual("Aungier Rental Red - Branded", self.car.getColour())
        self.car.paint(
            'red')  # this function exists for all child classes of car
        self.assertEqual('red', self.car.getColour())

    def test_car_engine(self):
        self.assertEqual('85-kWh', self.car1.getEngineSize())
        self.assertEqual('1.6 ltr', self.car2.getEngineSize())
        self.assertEqual('1.9 ltr', self.car3.getEngineSize())
        self.assertEqual('2.0 ltr', self.car4.getEngineSize())

    def test_rentalprocess(
        self
    ):  # test the rental process by renting out one car and checking it back in. verifies stock levels also
        self.assertEqual(0, len(self.dealership.rented_cars))
        self.assertEqual(8, len(self.dealership.hybrid_cars))
        self.dealership.rent(self.dealership.hybrid_cars, 1, "Test")
        self.assertEqual(1, len(self.dealership.rented_cars))
        self.assertEqual("Test", self.dealership.rented_cars[0][1])
        self.assertEqual(7, len(self.dealership.hybrid_cars))

        original_raw_input = __builtins__.raw_input
        __builtins__.raw_input = lambda _: "135"
        self.assertEqual(self.dealership.rented("Test"), None)
        __builtins__.raw_input = original_raw_input

        self.assertEqual(0, len(self.dealership.rented_cars))
        self.assertEqual(8, len(self.dealership.hybrid_cars))
示例#4
0
class TestDieselCar(TestEngineCar):
    def setUp(self):
        TestEngineCar.setUp(self)
        self.dieselCar = DieselCar()

    def test_diesel_default_constructor(self):
        self.assertEquals(False, self.dieselCar.turbo)

    def test_diesel_get_method(self):
        self.assertEquals(False, self.dieselCar.getDieselTurbo())

    def test_diesel_set_method(self):
        self.dieselCar.setDieselTurbo(True)
        self.assertEquals(True, self.dieselCar.getDieselTurbo())
class TestDieselCar(TestEngineCar):

    def setUp(self):
        TestEngineCar.setUp(self)
        self.dieselCar = DieselCar()

    def test_diesel_default_constructor(self):
        self.assertEquals(False, self.dieselCar.turbo)
        
    def test_diesel_get_method(self):
        self.assertEquals(False, self.dieselCar.getDieselTurbo())

    def test_diesel_set_method(self):
        self.dieselCar.setDieselTurbo(True)
        self.assertEquals(True, self.dieselCar.getDieselTurbo())
class TestDieselCar(TestEngineCar):
    def setUp(self):
        self.car = DieselCar()

    # this tests the default constructor
    def test_diesel_default_constructor(self):
        self.assertEqual(False, self.car.has_turbo_enabled)

    # this tests the getter functionality
    def test_diesel_getter(self):
        self.assertEqual(False, self.car.has_turbo_enabled)

    # this tests the setter functionality
    def test_diesel_setter(self):
        self.car.setTurbo(True)
        self.assertEqual(True, self.car.getTurbo())
示例#7
0
	def process_rental(self):
		answer = str.lower(raw_input('   Would you like to rent a car? Yes: "Y", No: "N" : '))
		if answer == 'y':
			answer = str.lower(raw_input('  Choose "p" for Petrol, "d" for Diesel, "e" for electric and "h" for Hybrid:   '))
			amount = int(raw_input('   How many would you like?  '))
			if answer == 'p':
				self.rent(self.petrol_cars, amount)
				choice = raw_input('   Write the model you would like: Toyota, Kia, Volkswagon, Ford:    ')
				petrol_car = PetrolCar()
				petrol_car.setMake(choice)
				mileage = int(raw_input('   Record the mileage here before you start driving. '))
				petrol_car.setMileage(mileage)
				print 'Your car is: ', petrol_car.getMake()
				print 'The current mileage is set at: ',  petrol_car.getMileage()
				return mileage
				
				
			elif answer == 'd':
				self.rent(self.diesel_cars, amount)
				choice = raw_input('   Write the model you would like: Nissan or Hyundai:  ')
				diesel_car = DieselCar()
				diesel_car.setMake(choice)
				mileage = int(raw_input('   Record the mileage here before you start driving. '))
				diesel_car.setMileage(mileage)
				print 'Your car is: ', diesel_car.getMake()
				print 'The current mileage is set at: ',  diesel_car.getMileage()
				return mileage
				
				
			elif answer == 'e':
				self.rent(self.electric_cars, amount)
				choice = raw_input('   We have a Nissan or a Tesla, please write your choice:   ')
				electric_car = ElectricCar()
				electric_car.setMake(choice)
				mileage = int(raw_input('   Record your mileage here before you start driving. '))
				electric_car.setMileage(mileage)
				print 'Your model is', electric_car.getMake()
				print 'Fuel cells available are', electric_car.getNumberFuelCells()
				print 'Your current mileage is set to:  ', electric_car.getMileage()
				return mileage
			else:
				self.rent(self.hybrid_cars, amount)			
				choice = raw_input(' what hybrid do you want, Prius or Lexus?  ')
				hybrid_car = HybridCar()
				hybrid_car.setMake(choice)
				mileage = int(raw_input('   Record your mileage here before you start driving.  '))
				hybrid_car.setMileage(mileage)
				print 'Your model is', hybrid_car.getMake()
				print 'Our hybrid cars come with :', hybrid_car.getNumberFuelCells(), 'fuel cells and ', hybrid_car.getNumberCylinders(), 'cylinders '
				print 'Your current mileage is set to:  ', hybrid_car.getMileage()
				return mileage
				
			car_fleet = CarFleet()
			car_fleet.rentCar(amount)
		if answer == 'n':
			self.process_returnCar()
		self.stock_count()
示例#8
0
 def test_diesel_car(self):
     car = DieselCar('Volksvagen', 'Passat', 'White', '01 P 1234', 1.5)
     self.assertEqual(car.get_make(), 'Volksvagen')
     self.assertEqual(car.get_model(), 'Passat')
     self.assertEqual(car.get_colour(), 'White')
     self.assertEqual(car.get_registration(), '01 P 1234')
     self.assertEqual(car.get_engine_size(), 1.5)
     self.assertEqual(car.get_is_rented(), False)
     self.assertEqual(
         str(car), 'Diesel,Volksvagen,Passat,White,01 P 1234,False,1.5,,\n')
示例#9
0
 def create_current_stock(self):
     for i in range(24):
         self.petrol_cars.append(PetrolCar())
     for i in range(8):
         self.diesel_cars.append(DieselCar())
     for i in range(4):
         self.electric_cars.append(ElectricCar())
     for i in range(4):
         self.hybrids.append(HybridCar())
示例#10
0
 def create_current_fleet(self):
     for i in range(6):
         self.electric_cars.append(ElectricCar())
     for i in range(20):
         self.petrol_cars.append(PetrolCar())
     for i in range(10):
         self.diesel_cars.append(DieselCar())
     for i in range(4):
         self.hybrid_cars.append(HybridCar())
示例#11
0
 def __init__(self):
     self.__petrol_cars = []
     self.__diesel_cars = []
     self.__electric_cars = []
     self.__hybrid_cars = []
     self.__csv_header = ''
     for i in range(1, 21):
         self.__petrol_cars.append(PetrolCar())
     for i in range(1, 11):
         self.__diesel_cars.append(DieselCar())
     for i in range(1, 7):
         self.__electric_cars.append(ElectricCar())
     for i in range(1, 5):
         self.__hybrid_cars.append(HybridCar())
示例#12
0
 def create_current_stock(self, typecar, start):
     #set up the initial stock for each type of cars
     # it has been called in the main (row 100)
     if typecar == 'E':
         for i in range(start):
             self.electric_cars.append(ElectricCar())
     elif typecar == 'P':
         for i in range(start):
             self.petrol_cars.append(PetrolCar())
     elif typecar == 'D':
         for i in range(start):
             self.diesel_cars.append(DieselCar())
     elif typecar == 'H':
         for i in range(start):
             self.hybrid_cars.append(HybridCar())
示例#13
0
 def create_current_stock(self):
     self.overallTotal = 40  # total stock the dealer plans on having initially
     uniqueID = 100  # each car will have it's own unique ID, this is the starting integer
     # Making an assumption here that the dealer will maintain the current
     # ratio of 50% petrol, 20% diesel, 10% electric and 20% hybrid
     # this could be changed to fixed qtys of each
     # 'build' the fleet!
     for i in range(int(self.overallTotal * 0.5)):
         self.petrol_cars.append(PetrolCar(uniqueID))
         uniqueID += 1
     for i in range(int(self.overallTotal * 0.2)):
         self.diesel_cars.append(DieselCar(uniqueID))
         uniqueID += 1
     for i in range(int(self.overallTotal * 0.2)):
         self.hybrid_cars.append(HybridCar(uniqueID))
         uniqueID += 1
     for i in range(int(self.overallTotal * 0.1)):
         self.electric_cars.append(ElectricCar(uniqueID))
         uniqueID += 1
示例#14
0
 def test_car_rental_set_methods(self):
     self.carRental.setFleet(40)
     self.assertEquals(40, self.carRental.getFleet())
     petrolCar = PetrolCar()
     dieselCar = DieselCar()
     electricCar = ElectricCar()
     hybridCar = HybridCar()
     self.carRental.setAvailablePetrolCars([petrolCar, petrolCar])
     self.assertEquals([petrolCar, petrolCar],
                       self.carRental.getAvailablePetrolCars())
     self.carRental.setAvailableDieselCars(
         [dieselCar, dieselCar, dieselCar])
     self.assertEquals([dieselCar, dieselCar, dieselCar],
                       self.carRental.getAvailableDieselCars())
     self.carRental.setAvailableElectricCars([electricCar, electricCar])
     self.assertEquals([electricCar, electricCar],
                       self.carRental.getAvailableElectricCars())
     self.carRental.setAvailableHybridCars([hybridCar, hybridCar])
     self.assertEquals([hybridCar, hybridCar],
                       self.carRental.getAvailableHybridCars())
示例#15
0
 def returnCar(self, carType):
     # checks car type
     if carType == 'Petrol':
         # call checkRentals function to determine whether or not the car type is on rentals
         index = self.checkRentals('Petrol')
         # if car type is in rentals then remove it from rentals and add it to the associated array
         if index != -1:
             self.rental_cars.pop(index)
             self.petrol_cars.append(PetrolCar())
             return 'You have returned the car'
         # else car type is not in rentals
         else:
             return 'No petrol cars currently on rental'
     elif carType == 'Diesel':
         index = self.checkRentals('Diesel')
         if index != -1:
             self.rental_cars.pop(index)
             self.petrol_cars.append(DieselCar())
             return 'You have returned the car'
         else:
             return 'No diesel cars currently on rental'
     elif carType == 'Electric':
         index = self.checkRentals('Electric')
         if index != -1:
             self.rental_cars.pop(index)
             self.petrol_cars.append(ElectricCar())
             return 'You have returned the car'
         else:
             return 'No electric cars currently on rental'
     elif carType == 'Hybrid':
         index = self.checkRentals('Hybrid')
         if index != -1:
             self.rental_cars.pop(index)
             self.petrol_cars.append(HybridCar())
             return 'You have returned the car'
         else:
             return 'No hybrids currently on rental'
示例#16
0
 def __load_diesel_car(self, cols):
     # Create diesel car from CSV line and add to diesel car list.
     car = DieselCar(cols[1], cols[2], cols[3], cols[4], float(cols[6]))
     self.__load_car_rental_status(car, cols[5])
     self.get_diesel_cars().append(car)
示例#17
0
 def setUp(self):
     TestEngineCar.setUp(self)
     self.dieselCar = DieselCar()
示例#18
0
 def setUp(self):
     TestCar.setUp(self)
     self.dieselCar = DieselCar()
示例#19
0
class CarRentalApp(object):

    ## create car objects
    global car, engineCar, petrolCar, dieselCar, electricCar, hybridCar, carRental
    car = Car()
    engineCar = EngineCar()
    petrolCar = PetrolCar()
    dieselCar = DieselCar()
    electricCar = ElectricCar()
    hybridCar = HybridCar()
    carRental = CarRental()

    ## create customer object
    global customer
    customer = Customer()

    def fleetInfo():
        ## construct car fleet
        carRental.setFleet(40)
        fleet = carRental.getFleet()
        availablePetrol = int(0.60 * fleet)
        availableDiesel = int(0.20 * fleet)
        availableElectric = int(0.10 * fleet)
        availableHybrid = int(0.10 * fleet)

        carRental.setAvailablePetrolCars([])
        carRental.setAvailableDieselCars([])
        carRental.setAvailableElectricCars([])
        carRental.setAvailableHybridCars([])
        for p in range(1, availablePetrol + 1):
            carRental.availablePetrolCars.append(petrolCar)
        for d in range(1, availableDiesel + 1):
            carRental.availableDieselCars.append(dieselCar)
        for e in range(1, availableElectric + 1):
            carRental.availableElectricCars.append(electricCar)
        for h in range(1, availableHybrid + 1):
            carRental.availableHybridCars.append(hybridCar)

    def customerDetails():

        ## print quit message
        print('Type "q" to quit this program')

        ## obtain input form user
        while True:
            name = input('Please enter Customer name: ')
            if name == 'q' or name == 'Q':
                quit()
            ## check user did not just press return button
            ## and all characters are alphabetic
            ## note: unfortunately the isalpha method will not work in cases
            ## whereby some african names contain an exclamation mark
            if name.isalpha() == False:
                print('Sorry, name not recognised.  Please try again.')
                continue
            customer.setName(name)
            licence = input('Please enter Customer driving licence number: ')
            if licence == 'q' or customer.licence == 'Q':
                quit()
            if licence == '':
                print('Sorry, licence not valid.  Please try again.')
                continue
            customer.setLicence(licence)
            print('Type "H" if Customer wishes to hire a car from the fleet.')
            print('Type "R" if Customer is returning a car to the fleet.')
            global hireReturn
            hireReturn = input('Hire or Return?: ')
            if hireReturn == 'q':
                quit()
            hireReturn = hireReturn.lower()
            if (hireReturn != 'h') and (hireReturn != 'r'):
                print('Invalid input.  Please try again.')
                continue
            break
        return hireReturn

    def carInfo():
        ## obtain car choice
        while True:
            print('What type of car is being hired/returned?:')
            print('Type "P" for petrol')
            print('Type "D" for diesel')
            print('Type "E" for electric')
            print('Type "H" for hybrid')
            global carChoice
            carChoice = input('Enter car type now: ')
            carChoice = carChoice.lower()
            if carChoice == 'q':
                quit()
            carChoiceOptions = ['p', 'd', 'e', 'h']
            ## check for valid carChoice
            if carChoice not in carChoiceOptions:
                print('Invalid car choice.  Please try agsin.')
                continue
            ## check if car choice available
            if hireReturn == 'h':
                if ( (carChoice == 'p') and (len(carRental.getAvailablePetrolCars()) <= 0) ) \
                or ( (carChoice == 'd') and (len(carRental.getAvailableDieselCars()) <= 0) ) \
                or ( (carChoice == 'e') and (len(carRental.getAvailableElectricCars()) <= 0) ) \
                or ( (carChoice == 'h') and (len(carRental.getAvailableHybridCars()) <= 0) ):
                    print(
                        'Apologies, there are none of this car type currently in the fleet.'
                    )
                    print('Please choose alternative car type.')
                    continue
            break
        return carChoice

    def transmissionInfo():
        ##obtain transmission info
        while True:
            if hireReturn == 'h':
                print(
                    'Does Customer prefer an Automatic or a Manual transmission?:'
                )
                print('Type "A" for Automatic')
                print('Type "M" for Manual')
                transmissionChoice = input('Enter transmission preference: ')
                transmissionChoice = transmissionChoice.lower()
                if transmissionChoice == 'q':
                    quit()
                transmissionChoiceOptions = ['a', 'm']
                ## check for valid transmissionChoice
                if transmissionChoice not in transmissionChoiceOptions:
                    print('Invalid transmission choice.  Please try agsin.')
                    continue
                if transmissionChoice == 'a':
                    engineCar.setTransmission('Automatic')
                if transmissionChoice == 'm':
                    engineCar.setTransmission('Manual')
            break

    def carMakeInfo():
        ##obtain car make info
        while True:
            if hireReturn == 'h':
                print('Does Customer prefer a Ford or a Toyota?:')
                print('Type "F" for Ford')
                print('Type "T" for Toyota')
                makeChoice = input('Enter Make preference: ')
                makeChoice = makeChoice.lower()
                if makeChoice == 'q':
                    quit()
                makeChoiceOptions = ['f', 't']
                ## check for valid makeChoice
                if makeChoice not in makeChoiceOptions:
                    print('Invalid Make choice.  Please try agsin.')
                    continue
                if makeChoice == 'f':
                    car.setMake('Ford')
                if makeChoice == 't':
                    car.setMake('Toyota')
            break

    def carModelInfo():
        ##obtain car model info
        while True:
            if car.getMake() == 'Ford':
                print('Does Customer prefer a Focus or a Mondeo?:')
                print('Type "F" for Focus')
                print('Type "M" for Mondeo')
                modelChoice = input('Enter Model preference: ')
                modelChoice = modelChoice.lower()
                if modelChoice == 'q':
                    quit()
                modelChoiceOptions = ['f', 'm']
                ## check for valid modelChoice
                if modelChoice not in modelChoiceOptions:
                    print('Invalid Model choice.  Please try agsin.')
                    continue
                if modelChoice == 'f':
                    car.setModel('Focus')
                if modelChoice == 'm':
                    car.setModel('Mondeo')
            break
        while True:
            if car.getMake() == 'Toyota':
                print('Does Customer prefer a Corolla or an Avensis?:')
                print('Type "C" for Corolla')
                print('Type "A" for Avensis')
                modelChoice = input('Enter Model preference: ')
                modelChoice = modelChoice.lower()
                if modelChoice == 'q':
                    quit()
                modelChoiceOptions = ['c', 'a']
                ## check for valid modelChoice
                if modelChoice not in modelChoiceOptions:
                    print('Invalid make choice.  Please try agsin.')
                    continue
                if modelChoice == 'c':
                    car.setModel('Corolla')
                if modelChoice == 'a':
                    car.setModel('Avensis')
            break

    def petrolCarInfo():
        ##obtain fuel info
        while True:
            if carChoice == 'p':
                print('Does Customer have a fuel preference?:')
                print('Type "L" for leaded')
                print('Type "U" for unleaded')
                fuelChoice = input('Enter Customer choice now: ')
                fuelChoice = fuelChoice.lower()
                if fuelChoice == 'q':
                    quit()
                fuelChoiceOptions = ['l', 'u']
                ## check for valid fuelChoice
                if fuelChoice not in fuelChoiceOptions:
                    print('Invalid fuel choice.  Please try agsin.')
                    continue
                if fuelChoice == 'l':
                    petrolCar.setPetrolType('Leaded')
                if fuelChoice == 'u':
                    petrolCar.setPetrolType('Unleaded')
            break

    def dieselCarInfo():
        ##obtain turbo info
        while True:
            if carChoice == 'd':
                print('Does Customer prefer standard or turbo?:')
                print('Type "S" for standard')
                print('Type "T" for turbo')
                turboChoice = input('Enter Customer choice now: ')
                turboChoice = turboChoice.lower()
                if turboChoice == 'q':
                    quit()
                turboChoiceOptions = ['s', 't']
                ## check for valid turboChoice
                if turboChoice not in turboChoiceOptions:
                    print('Invalid turbo choice.  Please try agsin.')
                    continue
                if turboChoice == 's':
                    dieselCar.setDieselTurbo(False)
                if turboChoice == 't':
                    dieselCar.setDieselTurbo(True)
            break

    def electricCarInfo():
        ##obtain fuelCells info
        while True:
            if carChoice == 'e':
                print('Does Customer prefer battery or capacitor?:')
                print('Type "B" for battery')
                print('Type "C" for capacitor')
                fuelCellsChoice = input('Enter Customer choice now: ')
                fuelCellsChoice = fuelCellsChoice.lower()
                if fuelCellsChoice == 'q':
                    quit()
                fuelCellsChoiceOptions = ['b', 'c']
                ## check for valid fuelCellsChoice
                if fuelCellsChoice not in fuelCellsChoiceOptions:
                    print('Invalid fuel cell choice.  Please try agsin.')
                    continue
                if fuelCellsChoice == 'b':
                    electricCar.setFuelCells('Battery')
                if fuelCellsChoice == 'c':
                    electricCar.setFuelCells('Capacitor')
            break

    def hybridCarInfo():
        ##obtain brake info
        while True:
            if carChoice == 'h':
                print(
                    'Does Customer prefer standard or regenerative braking system?:'
                )
                print('Type "S" for standard brake system')
                print('Type "R" for regenerative brake system')
                brakeChoice = input('Enter Customer choice now: ')
                brakeChoice = brakeChoice.lower()
                if brakeChoice == 'q':
                    quit()
                brakeChoiceOptions = ['s', 'r']
                ## check for valid brakeChoice
                if brakeChoice not in brakeChoiceOptions:
                    print('Invalid brake choice.  Please try agsin.')
                    continue
                if brakeChoice == 's':
                    hybridCar.setHybridBrake(False)
                if brakeChoice == 'r':
                    hybridCar.setHybridBrake(True)
            break

    def updateFleet(carChoice, hireReturn):
        ## remove/add one (1) car to/from fleet
        fleet = carRental.getFleet()
        if carChoice == 'p':
            if (hireReturn == 'h'):
                carRental.availablePetrolCars.pop()
                fleet -= 1
            elif (hireReturn == 'r'):
                carRental.availablePetrolCars.append(petrolCar)
                fleet += 1
            else:
                print('Hell has just frozen over.  Petrol debug necessary!')
                quit()
        elif carChoice == 'd':
            if (hireReturn == 'h'):
                carRental.availableDieselCars.pop()
                fleet -= 1
            elif (hireReturn == 'r'):
                carRental.availableDieselCars.append(dieselCar)
                fleet += 1
            else:
                print('Hell has just frozen over.  Diesel debug necessary!')
                quit()
        elif carChoice == 'e':
            if (hireReturn == 'h'):
                carRental.availableElectricCars.pop()
                fleet -= 1
            elif (hireReturn == 'r'):
                carRental.availableElectricCars.append(electricCar)
                fleet += 1
            else:
                print('Hell has just frozen over.  Electric debug necessary!')
                quit()
        elif carChoice == 'h':
            if (hireReturn == 'h'):
                carRental.availableHybridCars.pop()
                fleet -= 1
            elif (hireReturn == 'r'):
                carRental.availableHybridCars.append(hybridCar)
                fleet += 1
            else:
                print('Hell has just frozen over.  Hybrid debug necessary!')
                quit()
        else:
            print('Woah ... back up the apple-cart.  Debug required now!')
            quit()

    def calculateHirePeriod(hireReturn):
        while True:
            print('How many days does Customer require?')
            print('Number must be between 1 and 28 (inclusive).')
            hirePeriod = input('Please enter number of days: ')
            if hirePeriod == 'q':
                quit()
            try:
                hirePeriod = int(hirePeriod)
                if (1 <= hirePeriod) and (hirePeriod <= 28):
                    break
                else:
                    print('Hire period must be between 1 and 28.')
            except:
                print("Invalid input.  Try again.")
        return hirePeriod

    def calculateHireCharge(hireReturn, hirePeriod):
        ## hire rates for large cars (i.e. Avensis & Mondeo):
        ## are 50 euro per day for the first 10 days
        ## and 35 euro per day thereafter
        ## hire rates for small cars (i.e. Corolla & Focus):
        ## are 40 euro per day for the first 10 days
        ## and 25 euro per day thereafter
        if hirePeriod <= 10:
            if (car.getModel() == 'Avensis') or (car.getModel() == 'Mondeo'):
                hireCharge = hirePeriod * 50.00
            if (car.getModel() == 'Corolla') or (car.getModel() == 'Focus'):
                hireCharge = hirePeriod * 40.00
        elif (10 < hirePeriod) and (hirePeriod <= 28):
            if (car.getModel() == 'Avensis') or (car.getModel() == 'Mondeo'):
                hireCharge = 500 + ((hirePeriod - 10) * 35.00)
            if (car.getModel() == 'Corolla') or (car.getModel() == 'Focus'):
                hireCharge = 400 + ((hirePeriod - 10) * 25.00)
        else:
            print("Oops! ... we shouldn't be here!")
            quit()
        return hireCharge

    fleetInfo()
    hireReturn = customerDetails()
    carInfo()
    transmissionInfo()
    carMakeInfo()
    carModelInfo()
    petrolCarInfo()
    dieselCarInfo()
    electricCarInfo()
    hybridCarInfo()
    availableCars = updateFleet(carChoice, hireReturn)

    if hireReturn == 'h':
        customer.hirePeriod = calculateHirePeriod(hireReturn)
        customer.hireCharge = calculateHireCharge(hireReturn,
                                                  customer.hirePeriod)

    print('Customer name:\t\t\t', customer.getName())
    print('Customer licence:\t\t', customer.getLicence())
    if hireReturn == 'r':
        print('Thanks for returning the car.')
        print('Hope to see you again soom.')
    if hireReturn == 'h':
        print('Make of car hired:\t\t', car.getMake())
        print('Model of car hired:\t\t', car.getModel())
        print('Transmission of car hired:\t', engineCar.getTransmission())
        if carChoice == 'p':
            print('Petrol type:\t\t\t', petrolCar.getPetrolType())
        if carChoice == 'd':
            print('Has turbo?:\t\t\t', dieselCar.getDieselTurbo())
        if carChoice == 'e':
            print('Fuel cell type:\t\t\t', electricCar.getFuelCells())
        if carChoice == 'h':
            print('Regenerative braking system:\t', hybridCar.getHybridBrake())
        print('Hire period (days):\t\t', customer.hirePeriod)
        print('Hire charge (euro):\t\t', customer.hireCharge)
 def setUp(self):
     self.car = DieselCar()
示例#21
0
 def setUp(self):
     self.diesel = DieselCar()
示例#22
0
 def test_diesel_car_miles_gallon(self):
     diesel_car = DieselCar()
     self.assertEqual(0, diesel_car.getMilesGallon())
     diesel_car.setMilesGallon(20)
     self.assertEqual(20, diesel_car.getMilesGallon())
示例#23
0
"""
import pandas as pd
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
print('The colour is: ' + car4.getColour())

car4.setMileage(150)
car4.move(25)
print('The mileage is ' + str(car4.getMileage())) + 'kms'
car4.engineSize = '2.9'
print 'The engine size is ' + car4.engineSize

car4.setNumberOfFuelCylinders(3)
print('The number of fuel cylinders is ' + str(car4.getNumberOfFuelCylinders()))


# Car5 is calling a DieselCar objects and will implement its functions and variables.  Similar to other class'
# the car sets a model and returns it in this case Mercedes Benz, the colour is set as silver, the mileage is
# 1000 and increased by 40 to 1040 as the mileage returned, the engineSize is 3.2 and the car uses 5 cylinders.
car5 = DieselCar()
car5.setMake('Mercedes Benz')
print '\nOur diesel option is ' + car4.getMake()

car5.setColour('Silver')
print('The colour is ' + car5.getColour())

car5.setMileage(1000)
car5.move(40)
print('The mileage is ' + str(car5.getMileage())) + 'kms'
car5.engineSize = '3.2'
print 'The engine size is ' + car5.engineSize

car5.setNumberOfFuelCylinders(5)
print('The number of fuel cylinders is ' + str(car5.getNumberOfFuelCylinders()))
 def setUp(self):
     # The DieselCar calls itself using self.
     self.diesel_car = DieselCar()
示例#26
0
#We made that in our stock we have 40 cars, 4 different types, each type of the same make, model and specifications.

#Petrol car details.
carP = PetrolCar()
carP.setMake("Volkswagen Beetle")
carP.setColour("Blue")
carP.setNumberCylinders(4)
carP.setMileage(1000)
print " Make of Petrol car is      :" + carP.getMake()
print " Colour of the car is       :" + carP.getColour()
print " Number of cylinders        :" + str(carP.getNumberCylinders())
print " Mileage of Petrol car is   :" + str(carP.getMileage())
print "_________________________________________"

#Diesel car details.
carD = DieselCar()
carD.setMake("Audi Q7")
carD.setColour("Silver")
carD.setNumberCylinders(4)
carD.setMileage(500)
print " Make of Diesel car is      :" + carD.getMake()
print " Colour of the car is       :" + carD.getColour()
print " Number of cylinders        :" + str(carD.getNumberCylinders())
print " Milegae of Diesel car is   :" + str(carD.getMileage())
print "_________________________________________"

#Electric car details.
carE = ElectricCar()
carE.setMake("Nissan Leaf")
carE.setColour("Green")
carE.setNumberFuelCells(4)
示例#27
0
class CarRentalApp(object):

    ## create car objects
    global car, petrolCar, dieselCar, electricCar, hybridCar, carRental
    car = Car()
    #    engineCar = EngineCar()
    petrolCar = PetrolCar()
    dieselCar = DieselCar()
    electricCar = ElectricCar()
    hybridCar = HybridCar()
    carRental = CarRental()

    ## create customer object
    global customer
    customer = Customer()

    def fleetInfo():
        ## construct car fleet
        carRental.setFleet(40)
        fleet = carRental.getFleet()
        availablePetrol = int(0.50 * fleet)
        availableDiesel = int(0.20 * fleet)
        availableElectric = int(0.10 * fleet)
        availableHybrid = int(0.20 * fleet)

        carRental.setAvailablePetrolCars([])
        carRental.setAvailableDieselCars([])
        carRental.setAvailableElectricCars([])
        carRental.setAvailableHybridCars([])
        for p in range(1, availablePetrol + 1):
            carRental.availablePetrolCars.append(petrolCar)
        for d in range(1, availableDiesel + 1):
            carRental.availableDieselCars.append(dieselCar)
        for e in range(1, availableElectric + 1):
            carRental.availableElectricCars.append(electricCar)
        for h in range(1, availableHybrid + 1):
            carRental.availableHybridCars.append(hybridCar)

    def customerDetails():

        ## print quit message
        print 'Type "q" to quit this program'

        ## obtain input form user
        while True:
            name = raw_input('Enter Customer name please: ')
            if name == 'q' or name == 'Q':
                quit()
            if name.isalpha() == False:
                print 'Sorry, Please try again.'
                continue
            customer.setName(name)
            print 'Type "H" for hire a car from the fleet.'
            print 'Type "R" for a car to the fleet.'
            global hireReturn
            hireReturn = raw_input('Hire or Return?: ')
            if hireReturn == 'q':
                quit()
            hireReturn = hireReturn.lower()
            if (hireReturn != 'h') and (hireReturn != 'r'):
                print 'Invalid input.  Please try again.'
                continue
            break
        return hireReturn

    def carInfo():
        ## obtain car choice
        while True:
            print 'What type of car is being hired or returned?:'
            print 'Type "P" for petrol'
            print 'Type "D" for diesel'
            print 'Type "E" for electric'
            print 'Type "H" for hybrid'
            global carChoice
            carChoice = raw_input('Enter car type now: ')
            carChoice = carChoice.lower()
            if carChoice == 'q':
                quit()
            carChoiceOptions = ['p', 'd', 'e', 'h']
            ## check for valid carChoice
            if carChoice not in carChoiceOptions:
                print 'Invalid car choice.  Please try agsin.'
                continue
            ## check if car choice available
            if hireReturn == 'h':
                if ( (carChoice == 'p') and (len(carRental.getAvailablePetrolCars()) <= 0) ) \
                or ( (carChoice == 'd') and (len(carRental.getAvailableDieselCars()) <= 0) ) \
                or ( (carChoice == 'e') and (len(carRental.getAvailableElectricCars()) <= 0) ) \
                or ( (carChoice == 'h') and (len(carRental.getAvailableHybridCars()) <= 0) ):
                    print 'Sorry, there are none of this car type currently in the fleet.'
                    print 'Please choose alternative car type.'
                    continue
            break
        return carChoice

    def carMakeInfo():
        ##obtain car make info
        while True:
            if hireReturn == 'h':
                print 'Does Customer prefer a Ford or a Toyota?:'
                print 'Type "F" for Ford'
                print 'Type "T" for Toyota'
                makeChoice = raw_input('Enter Make preference: ')
                makeChoice = makeChoice.lower()
                if makeChoice == 'q':
                    quit()
                makeChoiceOptions = ['f', 't']
                ## check for valid makeChoice
                if makeChoice not in makeChoiceOptions:
                    print 'Invalid Make choice.  Please try again.'
                    continue
                if makeChoice == 'f':
                    car.setMake('Ford')
                if makeChoice == 't':
                    car.setMake('Toyota')
            break

    def carModelInfo():
        ##obtain car model info
        while True:
            if car.getMake() == 'Ford':
                print 'Does Customer prefer a Focus or a Mondeo?:'
                print 'Type "F" for Focus'
                print 'Type "M" for Mondeo'
                modelChoice = raw_input('Enter Model preference: ')
                modelChoice = modelChoice.lower()
                if modelChoice == 'q':
                    quit()
                modelChoiceOptions = ['f', 'm']
                ## check for valid modelChoice
                if modelChoice not in modelChoiceOptions:
                    print 'Invalid Model choice.  Please try agsin.'
                    continue
                if modelChoice == 'f':
                    car.setModel('Focus')
                if modelChoice == 'm':
                    car.setModel('Mondeo')
            break
        while True:
            if car.getMake() == 'Toyota':
                print 'Does Customer prefer a Corolla or an Avensis?:'
                print 'Type "C" for Corolla'
                print 'Type "A" for Avensis'
                modelChoice = raw_input('Enter Model preference: ')
                modelChoice = modelChoice.lower()
                if modelChoice == 'q':
                    quit()
                modelChoiceOptions = ['c', 'a']
                ## check for valid modelChoice
                if modelChoice not in modelChoiceOptions:
                    print 'Invalid make choice.  Please try agsin.'
                    continue
                if modelChoice == 'c':
                    car.setModel('Corolla')
                if modelChoice == 'a':
                    car.setModel('Avensis')
            break

    def petrolCarInfo():
        ##obtain fuel info
        while True:
            if carChoice == 'p':
                print 'Does Customer have a fuel preference?:'
                print 'Type "L" for leaded'
                print 'Type "U" for unleaded'
                fuelChoice = raw_input('Enter Customer choice now: ')
                fuelChoice = fuelChoice.lower()
                if fuelChoice == 'q':
                    quit()
                fuelChoiceOptions = ['l', 'u']
                ## check for valid fuelChoice
                if fuelChoice not in fuelChoiceOptions:
                    print 'Invalid fuel choice.  Please try agsin.'
                    continue
                if fuelChoice == 'l':
                    petrolCar.setPetrolType('Leaded')
                if fuelChoice == 'u':
                    petrolCar.setPetrolType('Unleaded')
            break

    def dieselCarInfo():
        ##obtain turbo info
        while True:
            if carChoice == 'd':
                print 'Does Customer prefer standard or turbo?:'
                print 'Type "S" for standard'
                print 'Type "T" for turbo'
                turboChoice = raw_input('Enter Customer choice now: ')
                turboChoice = turboChoice.lower()
                if turboChoice == 'q':
                    quit()
                turboChoiceOptions = ['s', 't']
                ## check for valid turboChoice
                if turboChoice not in turboChoiceOptions:
                    print 'Invalid turbo choice.  Please try agsin.'
                    continue
                if turboChoice == 's':
                    dieselCar.setDieselTurbo(False)
                if turboChoice == 't':
                    dieselCar.setDieselTurbo(True)
            break

    def electricCarInfo():
        ##obtain fuelCells info
        while True:
            if carChoice == 'e':
                print 'Does Customer prefer battery or capacitor?:'
                print 'Type "B" for battery'
                print 'Type "C" for capacitor'
                fuelCellsChoice = raw_input('Enter Customer choice now: ')
                fuelCellsChoice = fuelCellsChoice.lower()
                if fuelCellsChoice == 'q':
                    quit()
                fuelCellsChoiceOptions = ['b', 'c']
                ## check for valid fuelCellsChoice
                if fuelCellsChoice not in fuelCellsChoiceOptions:
                    print 'Invalid fuel cell choice.  Please try agsin.'
                    continue
                if fuelCellsChoice == 'b':
                    electricCar.setFuelCells('Battery')
                if fuelCellsChoice == 'c':
                    electricCar.setFuelCells('Capacitor')
            break

    def hybridCarInfo():
        ##obtain brake info
        while True:
            if carChoice == 'h':
                print 'Does Customer prefer standard or regenerative braking system?:'
                print 'Type "S" for standard brake system'
                print 'Type "R" for regenerative brake system'
                brakeChoice = raw_input('Enter Customer choice now: ')
                brakeChoice = brakeChoice.lower()
                if brakeChoice == 'q':
                    quit()
                brakeChoiceOptions = ['s', 'r']
                ## check for valid brakeChoice
                if brakeChoice not in brakeChoiceOptions:
                    print 'Invalid brake choice.  Please try agsin.'
                    continue
                if brakeChoice == 's':
                    hybridCar.setHybridBrake(False)
                if brakeChoice == 'r':
                    hybridCar.setHybridBrake(True)
            break

    def updateFleet(carChoice, hireReturn):
        ## remove/add one (1) car to/from fleet
        fleet = carRental.getFleet()
        if carChoice == 'p':
            if (hireReturn == 'h'):
                carRental.availablePetrolCars.pop()
                fleet -= 1
            elif (hireReturn == 'r'):
                carRental.availablePetrolCars.append(petrolCar)
                fleet += 1
            else:
                print 'Hell has just frozen over.  Petrol debug necessary!'
                quit()
        elif carChoice == 'd':
            if (hireReturn == 'h'):
                carRental.availableDieselCars.pop()
                fleet -= 1
            elif (hireReturn == 'r'):
                carRental.availableDieselCars.append(dieselCar)
                fleet += 1
            else:
                print 'Hell has just frozen over.  Diesel debug necessary!'
                quit()
        elif carChoice == 'e':
            if (hireReturn == 'h'):
                carRental.availableElectricCars.pop()
                fleet -= 1
            elif (hireReturn == 'r'):
                carRental.availableElectricCars.append(electricCar)
                fleet += 1
            else:
                print 'Hell has just frozen over.  Electric debug necessary!'
                quit()
        elif carChoice == 'h':
            if (hireReturn == 'h'):
                carRental.availableHybridCars.pop()
                fleet -= 1
            elif (hireReturn == 'r'):
                carRental.availableHybridCars.append(hybridCar)
                fleet += 1
            else:
                print 'Hell has just frozen over.  Hybrid debug necessary!'
                quit()
        else:
            print 'Woah ... back up the apple-cart.  Debug required now!'
            quit()

    def calculateHirePeriod(hireReturn):
        while True:
            print 'How many days does Customer require?'
            print 'Number must be between 1 and 28 (inclusive).'
            hirePeriod = raw_input('Please enter number of days: ')
            if hirePeriod == 'q':
                quit()
            try:
                hirePeriod = int(hirePeriod)
                if (1 <= hirePeriod) and (hirePeriod <= 28):
                    break
                else:
                    print 'Hire period must be between 1 and 28.'
            except:
                print "Invalid input.  Try again."
        return hirePeriod

    def calculateHireCharge(hireReturn, hirePeriod):

        if hirePeriod <= 10:
            if (car.getModel() == 'Avensis') or (car.getModel() == 'Mondeo'):
                hireCharge = hirePeriod * 60.00
            if (car.getModel() == 'Corolla') or (car.getModel() == 'Focus'):
                hireCharge = hirePeriod * 50.00
        elif (10 < hirePeriod) and (hirePeriod <= 28):
            if (car.getModel() == 'Avensis') or (car.getModel() == 'Mondeo'):
                hireCharge = 500 + ((hirePeriod - 10) * 30.00)
            if (car.getModel() == 'Corolla') or (car.getModel() == 'Focus'):
                hireCharge = 400 + ((hirePeriod - 10) * 20.00)
        else:
            print "we shouldn't be here!"
            quit()
        return hireCharge

    fleetInfo()
    hireReturn = customerDetails()
    carInfo()
    carMakeInfo()
    carModelInfo()
    petrolCarInfo()
    dieselCarInfo()
    electricCarInfo()
    hybridCarInfo()
    availableCars = updateFleet(carChoice, hireReturn)

    if hireReturn == 'h':
        customer.hirePeriod = calculateHirePeriod(hireReturn)
        customer.hireCharge = calculateHireCharge(hireReturn,
                                                  customer.hirePeriod)

    print 'Customer name:\t\t\t', customer.getName()
    if hireReturn == 'r':
        print 'Thanks for returning the car.'
    if hireReturn == 'h':
        print 'Make of car hired:\t\t', car.getMake()
        print 'Model of car hired:\t\t', car.getModel()
        #        print 'Transmission of car hired:\t', Car.getTransmission()
        if carChoice == 'p':
            print 'Petrol type:\t\t\t', petrolCar.getPetrolType()
        if carChoice == 'd':
            print 'Has turbo?:\t\t\t', dieselCar.getDieselTurbo()
        if carChoice == 'e':
            print 'Fuel cell type:\t\t\t', electricCar.getFuelCells()
        if carChoice == 'h':
            print 'Regenerative braking system:\t', hybridCar.getHybridBrake()
        print 'Hire period (days):\t\t', customer.hirePeriod
        print 'Hire charge (euro):\t\t', customer.hireCharge
示例#28
0
 def test_diesel_car_fuel_cylinders(self):
     diesel_car = DieselCar()
     self.assertEqual(1, diesel_car.getNumberCylinders())
     diesel_car.setNumberCylinders(4)
     self.assertEqual(4, diesel_car.getNumberCylinders())
示例#29
0
#Petrol car
car2 = PetrolCar()
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')
 def setUp(self):
     TestEngineCar.setUp(self)
     self.dieselCar = DieselCar()
class TestDieselCar(unittest.TestCase):
    def setUp(self):
        # The DieselCar calls itself using self.
        self.diesel_car = DieselCar()

    def test_DieselCar_fuel_cylinders(self):
        # This tests fuel_cylinders for a DieselCar class similar to a petrol car however the default value for
        # number of cylinders is higher for diesel.  Then setNumberOfFuelCylinders method calls the function
        # from the base class DieselCar to change the value to 8.  This is tested and confirmed to be true.
        # The next tests test cylinders for the values 2 and 4 which are confirmed in the test cases as true.
        self.assertEqual(5, self.diesel_car.getNumberOfFuelCylinders())
        self.diesel_car.setNumberOfFuelCylinders(8)
        self.assertEqual(8, self.diesel_car.getNumberOfFuelCylinders())
        self.diesel_car.setNumberOfFuelCylinders(2)
        self.assertEqual(2, self.diesel_car.getNumberOfFuelCylinders())
        self.diesel_car.setNumberOfFuelCylinders(4)
        self.assertEqual(4, self.diesel_car.getNumberOfFuelCylinders())

    def test_DieselCar_mileage_and_move(self):
        # Function for testing the mileage of a DieselCar class.  As with other cars the default value is 0.
        # The move function is called taking the value 8.  This moves the car by 8km's.  Next it is increased
        # by 20 to make 28, tested with increasing by 0 and remains 28.  The setMileage function calls the function
        # in the DieselCar class which inherits the function from the Car class.  This sets mileage at 30 which is
        # tested and is true and lastly move by 7.5 to increase mileage to 37.5 which is tested and is true.
        self.assertEqual(0, self.diesel_car.getMileage())
        self.diesel_car.move(8)
        self.assertEqual(8, self.diesel_car.getMileage())
        self.diesel_car.move(20)
        self.assertEqual(28, self.diesel_car.getMileage())
        self.diesel_car.move(0)
        self.assertEqual(28, self.diesel_car.getMileage())
        self.diesel_car.setMileage(30)
        self.assertEqual(30, self.diesel_car.getMileage())
        self.diesel_car.move(7.5)
        self.assertEqual(37.5, self.diesel_car.getMileage())

    def test_DieselCar_make(self):
        # Testing make function for DieselCar.
        self.assertEqual(' ', self.diesel_car.getMake())
        self.diesel_car.setMake('Chevy')
        self.assertEqual('Chevy', self.diesel_car.getMake())
        self.diesel_car.setMake('Chevy Impala')
        self.assertEqual('Chevy Impala', self.diesel_car.getMake())
        self.diesel_car.setMake('Chevrolet Silverado 2500 HD')
        self.assertEqual('Chevrolet Silverado 2500 HD', self.diesel_car.getMake())

    def test_DieselCar_engineSize(self):
        # Testing engineSize for DieselCar class.
        self.assertEqual(' ', self.diesel_car.getEngineSize())
        self.diesel_car.setEngineSize(3.3)
        self.assertEqual(3.3, self.diesel_car.getEngineSize())
        self.diesel_car.setEngineSize(3.5)
        self.assertEqual(3.5, self.diesel_car.getEngineSize())

    def test_DieselCar_colour_and_paint(self):
        # Testing colour and paint for DieselCar Class.
        self.assertEqual(' ', self.diesel_car.getColour())
        self.diesel_car.paint('silver')
        self.assertEqual('silver', self.diesel_car.getColour())
        self.diesel_car.setColour('white')
        self.assertEqual('white', self.diesel_car.getColour())

    class TestHybridCar(unittest.TestCase):
        def setUp(self):
            # The HybridCar calls itself using self.
            self.hybrid_car = HybridCar()

        def test_HybridCar_fuel_cylinders(self):
            # Similar to petrol and diesel except default value is 1.  The default value is tested as well as 4, 6
            # and 3 which all result in true.
            self.assertEqual(1, self.hybrid_car.getNumberOfFuelCylinders())
            self.hybrid_car.setNumberOfFuelCylinders(4)
            self.assertEqual(4, self.hybrid_car.getNumberOfFuelCylinders())
            self.hybrid_car.setNumberOfFuelCylinders(6)
            self.assertEqual(6, self.hybrid_car.getNumberOfFuelCylinders())
            self.hybrid_car.setNumberOfFuelCylinders(3)
            self.assertEqual(3, self.hybrid_car.getNumberOfFuelCylinders())

        def test_HybridCar_fuel_cells(self):
            # Similar to ElectricCar test_car_fuel_cells.  The default value 1 is tested as well as 4 and 2.
            self.assertEqual(1, self.hybrid_car.getNumberOfFuelCells())
            self.hybrid_car.setNumberOfFuelCells(4)
            self.assertEqual(4, self.hybrid_car.getNumberOfFuelCells())
            self.hybrid_car.setNumberOfFuelCells(2)
            self.assertEqual(2, self.hybrid_car.getNumberOfFuelCells())

        def test_HybridCar_mileage_and_move(self):
            # As in other cases testing the mileage default value.  Then entering a value for move to ensure
            # it moves that amount to test the mileage of a car.  The car is moved by 7.7 to make 19.7 moved 0
            # output stays the same and lastly setMileage is tested with a value of 15 which is true.
            self.assertEqual(0, self.hybrid_car.getMileage())
            self.hybrid_car.move(12)
            self.assertEqual(12, self.hybrid_car.getMileage())
            self.hybrid_car.move(7.7)
            self.assertEqual(19.7, self.hybrid_car.getMileage())
            self.hybrid_car.move(0)
            self.assertEqual(19.7, self.hybrid_car.getMileage())
            self.hybrid_car.setMileage(15)
            self.assertEqual(15, self.hybrid_car.getMileage())

        def test_HybridCar_make(self):
            # Testing make function for HybridCar.
            self.assertEqual(' ', self.hybrid_car.getMake())
            self.hybrid_car.setMake('Chevrolet Malibu')
            self.assertEqual('Chevrolet Malibu', self.hybrid_car.getMake())
            self.hybrid_car.setMake('Chevrolet Cruz')
            self.assertEqual('Chevrolet Cruz', self.hybrid_car.getMake())

        def test_HybridCar_engineSize(self):
            # Testing engineSize for HybridCar.
            self.assertEqual(' ', self.hybrid_car.getEngineSize())
            self.hybrid_car.setEngineSize(1.6)
            self.assertEqual(1.6, self.hybrid_car.getEngineSize())
            self.hybrid_car.setEngineSize(1.8)
            self.assertEqual(1.8, self.hybrid_car.getEngineSize())

        def test_HybridCar_colour_and_paint(self):
            # Testing colour and paint for HybridCar.
            self.assertEqual(' ', self.hybrid_car.getColour())
            self.hybrid_car.paint('red')
            self.assertEqual('red', self.hybrid_car.getColour())
            self.hybrid_car.setColour('light blue')
            self.assertEqual('light blue', self.hybrid_car.getColour())