Question: class Fleet(object): fleet_count = 0 car_desc = DMC DeLorean def get_vin(self): return self.__vin def get_year(self): return self.__year def get_odometer(self): return self.__odometer def set_odometer(self, miles): if

class Fleet(object): fleet_count = 0 car_desc = "DMC DeLorean" def get_vin(self): return self.__vin def get_year(self): return self.__year def get_odometer(self): return self.__odometer def set_odometer(self, miles): if miles > self.__odometer: #so odometer doesn't roll back self.__odometer = miles odo_reading = property(get_odometer, set_odometer) def get_rent_miles(self): return self.__rent_miles def get_rent_days(self): return self.__rent_days def get_rent_count(self): return self.__rent_count def __init__(self,vin,year,odometer,color="",rent_miles=0,rent_days=0,rent_count=0): self.__vin = vin self.__year = year self.color = color self.__odometer = odometer self.__rent_miles = rent_miles self.__rent_days = rent_days self.__rent_count = rent_count Fleet.fleet_count += 1 def process_rental(self,odo,days): miles = odo - self.odo_reading self.__rent_miles += miles self.odo_reading = odo self.__rent_days += days self.__rent_count += 1 def calc_age(self,curr_yr): age = curr_yr - self.__year return age def sell_car(self,curr_yr): if self.calc_age(curr_yr) > 3 or self.odo_reading > 50000: return True else: return False def print_carinfo(self): print("VIN:",self.__vin) print("Car:",Fleet.car_desc) print("Year:",self.__year) print("Color:",self.color) print("Odometer:",self.__odometer) car1 = Fleet("101",2016,40000,"Blue",35000,600,50) car2 = Fleet("102",2019,15,"Red") newcar = input("New car data? Y/N: ") if newcar.upper() == "Y": new_vin = input("Enter VIN: ") new_year = int(input("Enter model year: ")) new_odo = int(input("Enter odometer reading: ")) new_color = input("Enter color: ") car3 = Fleet(new_vin,new_year,new_odo,new_color) car3.print_carinfo() car1.print_carinfo() car1.process_rental(42065,10) car2.process_rental(1181,3) car2.process_rental(1400,3) car2.process_rental(2122,5) car1.odo_reading = 42080 #service trip so not increment rent_count car2.process_rental(3123,7) car1.process_rental(44786,12) car1.color = "Yellow" #paint job car2.process_rental(4357,14) car1.print_carinfo() yr = int(input("What is the current year? ")) print("Time to sell the above car:",car1.sell_car(yr)) print("Number of cars in fleet:",Fleet.fleet_count) print() def print_metrics(car_obj,curr_yr): #could have been method in class instead car_obj.print_carinfo() age = car_obj.calc_age(curr_yr) + 1 print("Rental miles per year:",round(car_obj.get_rent_miles() / age)) print("Rental days per year:",round(car_obj.get_rent_days() / age)) print("No. of rentals per year:",round(car_obj.get_rent_count() / age)) print("Miles per rental:",round(car_obj.get_rent_miles() / car_obj.get_rent_count())) print("Days per rental:",round(car_obj.get_rent_days() / car_obj.get_rent_count())) print() print_metrics(car1,yr) print_metrics(car2,yr) #no metrics for car3 as no transactions added for car3

Fancy Car Rentals, Inc. has diversified its business and so the requirements from above have been extended. It now also rents out trucks, which are also identified as DMC DeLorean. Cars are rented out at $100 per day with unlimited mileage. Trucks are rented out at $85 per day with a $0.50 charge per mile. Also, in order to continue to qualify for special small business tax incentives, the total fleet size (including cars and trucks) must not exceed 10. Other aspects of the business have not changed. Additionally, add the functionality to obtain the bill amount for each rental.

The next step is to read data about the rental fleet from a file (fleet.txt), process some transactions provided in a file (transaction.txt), and store the updated data back to the fleet.txt file. The program should also calculate and display the total revenue across all the rental transactions, identify any vehicles (by VIN) that should be sold, and show the number of additional vehicles that may be acquired currently without giving up any tax incentives. The user should be prompted to enter the current year.

Note that each row of the fleet.txt file contains data (separated by commas) about one vehicle. The first row of the file shows in order the names of the data attributes in the file. The transaction.txt file does not contain such a header row. Each row in the file has data (separated by commas) on one transaction. The first data item is the vehicle VIN. Each transaction may be one of three types (R, S, or P) indicated by the second data item. Rental (R) data rows also contain the odometer reading at the end of the rental and number of rental days in that order. Service (S) data rows contain the odometer reading at the end of the service trip. Paint (P) job data rows contain the new color the car was painted.

Data in fleet.txt

VIN,Type,Year,Odometer,Color,RentalMiles,RentalDays,RentalCount

101,C,2016,40000,Blue,35000,600,50

102,T,2021,15,Red,0,0,0

transaction.txt

101,R,42065,10

102,R,1181,3

102,R,1400,3

102,R,2122,5

101,S,42080

102,R,3123,7

101,R,44786,12

101,P,Yellow

102,R,4357,14

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!