Ejemplo n.º 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.")
Ejemplo n.º 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 ")        
def main():
    shop = BikeRental(100)
    customer = Customer()

    while True:
        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 = int(input("enter choice: "))

        try:
            int(choice)
        except:
            print("this is not integer input")
            continue

        if choice == 1:
            shop.display_stock()

        elif choice == 2:
            customer.rentalTime = shop.rent_bike_on_hourly_basis(
                customer.requestBike())
            customer.rentalBasis = 1

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

        elif choice == 4:
            customer.rentalTime = shop.rent_bike_on_weekly_basis(
                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("Please enter given option which on Screen (1-6) ")
    print("Thank you for using the bike rental system.")
Ejemplo n.º 4
0
    def test_return_Bike_with_invalid_input(self):
        # create a customer
        customer = Customer()

        # create valid rentalBasis and bikes

        customer.rentalBasis = 1
        customer.bikes = 0  # create invalid rentalTime
        customer.rentalTime = 0
        self.assertEqual(customer.returnBike(), (0, 0, 0))
Ejemplo n.º 5
0
    def test_return_Bike_with_valid_input(self):
        # create a customer
        customer = Customer()

        # create valid rentalTime, rentalBasis, bikes
        now = datetime.now()
        customer.rentalTime = now
        customer.rentalBasis = 1
        customer.bikes = 4
        self.assertEqual(customer.returnBike(), (now, 1, 4))
Ejemplo n.º 6
0
    def test_returnBike_for_invalid_rentalBasis(self):
        # create a shop and a customer
        shop = BikeRental(10)
        customer = Customer()

        # create valid rentalTime and bikes
        customer.rentalTime = datetime.now()
        customer.bikes = 3
        # create invalid rentalbasis
        customer.rentalBasis = 7
        request = customer.returnBike()
        self.assertEqual(shop.returnBike(request), 0)
Ejemplo n.º 7
0
    def test_returnBike_for_invalid_numOfBikes(self):
        # create a shop and a customer
        shop = BikeRental(10)
        customer = Customer()

        # create valid rentalTime and rentalBasis
        customer.rentalTime = datetime.now()
        customer.rentalBasis = 1
        # create invalid bikes
        customer.bikes = 0
        request = customer.returnBike()
        self.assertIsNone(shop.returnBike(request))
Ejemplo n.º 8
0
    def test_returnBike_for_valid_credentials(self):
        print("\nValid Credentials")
        # create a shop and a various customers
        shop = BikeRental(50)
        customer1 = Customer()
        customer2 = Customer()
        customer3 = Customer()
        customer4 = Customer()
        customer5 = Customer()
        customer6 = Customer()

        # create valid rentalBasis for each customer
        customer1.rentalBasis = 1  # hourly
        customer2.rentalBasis = 1  # hourly
        customer3.rentalBasis = 2  # daily
        customer4.rentalBasis = 2  # daily
        customer5.rentalBasis = 3  # weekly
        customer6.rentalBasis = 3  # weekly

        # create valid bikes for each customer
        customer1.bikes = 1
        customer2.bikes = 5  # eligible for family discount 30%
        customer3.bikes = 2
        customer4.bikes = 8
        customer5.bikes = 15
        customer6.bikes = 30

        # create past valid rental times for each customer

        customer1.rentalTime = datetime.now() + timedelta(hours=-4)
        customer2.rentalTime = datetime.now() + timedelta(hours=-23)
        customer3.rentalTime = datetime.now() + timedelta(days=-4)
        customer4.rentalTime = datetime.now() + timedelta(days=-13)
        customer5.rentalTime = datetime.now() + timedelta(weeks=-6)
        customer6.rentalTime = datetime.now() + timedelta(weeks=-12)

        # make all customers return their bikes
        request1 = customer1.returnBike()
        request2 = customer2.returnBike()
        request3 = customer3.returnBike()
        request4 = customer4.returnBike()
        request5 = customer5.returnBike()
        request6 = customer6.returnBike()

        # check if all of them get correct bill
        self.assertEqual(shop.returnBike(request1), 20)
        self.assertEqual(shop.returnBike(request2), 402.5)
        self.assertEqual(shop.returnBike(request3), 160)
        self.assertEqual(shop.returnBike(request4), 2080)
        self.assertEqual(shop.returnBike(request5), 5400)
        self.assertEqual(shop.returnBike(request6), 21600)