Example #1
0
 def test_hybrid_car_fuel_cells(self):
     hybrid_car = HybridCar()
     self.assertEqual(1, hybrid_car.getNumberFuelCells())
     hybrid_car.setNumberFuelCells(2)
     self.assertEqual(2, hybrid_car.getNumberFuelCells())
     self.assertEqual(1, hybrid_car.getNumberCylinders())
     hybrid_car.setNumberCylinders(2)
     self.assertEqual(2, hybrid_car.getNumberCylinders())
Example #2
0
 def test_hybrid_car_cylinders(self):
     hybrid_car = HybridCar()
     self.assertEqual(1, hybrid_car.getNumberCylinders())
     hybrid_car.setNumberCylinders(4)
     self.assertEqual(4, hybrid_car.getNumberCylinders())
Example #3
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(
                )

            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(
                )

            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(
                )

            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(
                )
            car_fleet = CarFleet()
            car_fleet.rentCar(amount)
        if answer == 'n':
            self.process_returnCar()
        self.stock_count()