Exemple #1
0
def main():

    shop= BikeRental(100)
    customer= Customer()

    while True:
        print("""
        ====== Welcome to 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 integer..!!")
            continue
        
        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:
            break

        else:
            print("Invalid input. Please enter number between 1-6 ")

    print("Thank you for using the bike rental system.")
Exemple #2
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 ")        
Exemple #3
0
 def test_Bike_Rental_diplays_correct_stock(self):
     print("\nDisplay Stock Test")
     shop1 = BikeRental()
     shop2 = BikeRental(10)
     self.assertEqual(shop1.displaystock(), 0)
     self.assertEqual(shop2.displaystock(), 10)