Beispiel #1
0
def startshop():
    while 1 == True:
        shop = BikeRental(100)
        customer = Customer()
        print("""
            ====== Bike Rental Shop =======
            1. Display available bikes
            2. Request a bike on hourly basis $5
            3. Request a bike on daily basis $20
            4. Request a bike on weekly basis $60
            5. Return a bike
            6. Exit
            """)
            
        choice = input("Enter choice: ")
            
        try:
            choice = int(choice)
        except ValueError:
            print("That's not an int!")
            pass
        
        if choice == 1:
            shop.displaystock()
        
        elif choice == 2:
            customer.rentalTime = shop.rentBikeOnHourlyBasis(customer.requestBike())
            customer.rentalBasis = 1

        elif choice == 3:
            customer.rentalTime = shop.rentBikeOnDailyBasis(customer.requestBike())
            customer.rentalBasis = 2

        elif choice == 4:
            customer.rentalTime = shop.rentBikeOnWeeklyBasis(customer.requestBike())
            customer.rentalBasis = 3

        elif choice == 5:
            customer.bill = shop.returnBike(customer.returnBike())
            customer.rentalBasis, customer.rentalTime, customer.bikes = 0,0,0        
        elif choice == 6:
            clear()
            print("""
                ====== Bike Rental Shop =======
                Thank you for using the bike rental system.
                """)
            sleep(2)
            clear()
            exit()
        else:
                print("Invalid input. Please enter number between 1-6 ")        
Beispiel #2
0
 def test_rentBikeOnWeeklyBasis_for_invalid_positive_number_of_bikes(self):
     print("\nRent Bike Weekly Not enough stock !")
     shop = BikeRental(10)
     self.assertEqual(shop.rentBikeOnWeeklyBasis(11), None)
Beispiel #3
0
 def test_rentBikeOnWeeklyBasis_for_valid_positive_number_of_bikes(self):
     print("\nRent Bike Weekly Success!")
     shop = BikeRental(10)
     hour = datetime.now().hour
     self.assertEqual(shop.rentBikeOnWeeklyBasis(2).hour, hour)
Beispiel #4
0
 def test_rentBikeOnWeeklyBasis_for_zero_number_of_bikes(self):
     print("\nRent Bike Weekly zero bike!")
     shop = BikeRental(10)
     self.assertEqual(shop.rentBikeOnWeeklyBasis(0), None)
Beispiel #5
0
 def test_rentBikeOnWeeklyBasis_for_negative_number_of_bikes(self):
     print("\nRent Bike Weekly neg bike!")
     shop = BikeRental(10)
     self.assertEqual(shop.rentBikeOnWeeklyBasis(-1), None)
Beispiel #6
0
 def test_rentBikeOnWeeklyBasis_for_invalid_positive_number_of_bikes(self):
     shop = BikeRental(10)
     self.assertEqual(shop.rentBikeOnWeeklyBasis(11), None)