示例#1
0
 def test_two_bikes_four_weeks(self):
     app = Rental('week', 4, 2)
     self.assertEqual(app.rent_bikes(), 480,
                      'Wrong price for rental of 2 bikes 4 weeks')
示例#2
0
 def test_four_bikes_six_weeks(self):
     app = Rental('week', 6, 4)
     self.assertEqual(app.rent_bikes(), 1008,
                      'Wrong price for rental of 4 bikes 6 weeks')
示例#3
0
 def test_one_bike_one_hour(self):
     app = Rental('hour', 1, 1)
     self.assertEqual(app.rent_bikes(), 5,
                      'Wrong price for rental of 1 bike 1 hour')
示例#4
0
 def test_one_bike_three_weeks(self):
     app = Rental('week', 3, 1)
     self.assertEqual(app.rent_bikes(), 180,
                      'Wrong price for rental of 1 bike 3 weeks')
示例#5
0
 def test_four_bikes_six_days(self):
     app = Rental('day', 6, 4)
     self.assertEqual(app.rent_bikes(), 336,
                      'Wrong price for rental of 4 bikes 6 days')
示例#6
0
 def test_one_bike_one_week(self):
     app = Rental('week', 1, 1)
     self.assertEqual(app.rent_bikes(), 60,
                      'Wrong price for rental of 1 bike 1 week')
示例#7
0
 def test_one_bike_three_days(self):
     app = Rental('day', 3, 1)
     self.assertEqual(app.rent_bikes(), 60,
                      'Wrong price for rental of 1 bike 3 days')
示例#8
0
 def test_two_bikes_four_days(self):
     app = Rental('day', 4, 2)
     self.assertEqual(app.rent_bikes(), 160,
                      'Wrong price for rental of 2 bikes 4 days')
示例#9
0
 def test_one_bike_one_day(self):
     app = Rental('day', 1, 1)
     self.assertEqual(app.rent_bikes(), 20,
                      'Wrong price for rental of 1 bike 1 day')
示例#10
0
 def test_four_bikes_seven_hour(self):
     app = Rental('hour', 7, 4)
     self.assertEqual(app.rent_bikes(), 98,
                      'Wrong price for rental of 4 bikes 7 hours')
示例#11
0
 def test_two_bikes_two_hours(self):
     app = Rental('hour', 2, 2)
     self.assertEqual(app.rent_bikes(), 20,
                      'Wrong price for rental of 2 bikes 2 hours')
示例#12
0
 def test_one_bike_three_hours(self):
     app = Rental('hour', 3, 1)
     self.assertEqual(app.rent_bikes(), 15,
                      'Wrong price for rental of 1 bike 3 hours')
示例#13
0
文件: app.py 项目: MaiBil/bike_rental
            continue

    # Get amount of time (number of hours/days/weeks)
    while True:
        try:
            amount_of_time = int(
                input(f'For how many {time_unit}s would you like to rent? '))
            break
        except ValueError:
            print('Not a valid value! Try again')
            continue

    # Get number of bikes
    while True:
        try:
            number_of_bikes = int(
                input('And how many bikes would you like to rent? '))
            break
        except ValueError:
            print('Not a valid value! Try again')
            continue

    # Create an instance (this_rental) of class Rental with the values provided by the user
    this_rental = Rental(time_unit, amount_of_time, number_of_bikes)

    # Calculate the price for this rental
    total_price = this_rental.rent_bikes()

    # Renturn the total price of the rental to the user
    print(f'Total price: ${total_price}')