Question: The following is an algorithm that was produced for HW09A. The assignment is to write a program from this in Python and then incorporate the

The following is an algorithm that was produced for HW09A. The assignment is to write a program from this in Python and then incorporate the additional requirements at the bottom.

Define class named Fleet

Class attributes:

fleet_count which is the count of total no. of vehicles initially set to 0

car_desc set to DMC_Delorean as it applies to all vehicles

max_fleet set to 10

Instance attributes:

vin which is a vehicles VIN (unique id no.) (private read/get only)

year which is a vehicles model year (private read/get only)

color which is a vehicles color

odometer which is a vehicles current odometer reading (private get & set)

rent_miles which is a vehicles total of miles rented (private read/get only)

rent_days which is a vehicles total of days rented (private read/get only)

rent_count which is a vehicles total no. of times rented (private read/get only)

Methods (note: all require the current object self as input):

Need custom constructor method (__init__) as some attributes are private. Input will be values for the seven instance attributes and the method will assign those values to attributes.

Method should increment fleet.count

Get methods to return all private attribute values one method per attribute

Set method for odometer with input odometer reading (variable miles)

C: miles greater than odometer attribute value (so odometer not rolled back)

T: private attribute odometer = miles

Optionally, could create a property as an interface for the get and set methods for odometer

process_rental - inputs ending odometer reading (variable odo) and days rented (variable days)

Calculate miles driven on rental (miles) as odo minus odometer attribute value

Increment the rent_miles attribute value by miles

Set the odometer attribute to odo

Increment the rent_days attribute value by days

Increment the rent_count attribute value by 1

Call the calc_bill method (pass miles and days) and return the bill amount

calc_age input current year (variable curr_yr)

Calculate age as curr_yr minus the year attribute value

Provide/return age as output

sell_vehicle input current year (variable curr_yr)

Call the calc_age method (pass curr_yr) and store output in variable age

C: age greater than 3 or odometer attribute value > 50000

T: provide/return True as output

F: provide/return False as output

print_info no input

Display "VIN:" and vin attribute value

Display "Make:" and car_desc attribute value

Display "Year:" and year attribute value

Display "Color:" and color attribute value

Display "Odometer:" and odometer attribute value

Define class named Car as sub-class of Fleet

Class attributes:

daily_rate set to 100

Methods (note: requires the current object self as input):

calc_bill inputs miles driven on rental (variable miles) and days rented (variable days)

Calculate bill as days times daily_rate (for cars or self)

Provide/return bill as output

Define class named Truck as sub-class of Fleet

Class attributes:

daily_rate set to 85

mile_rate set to 0.50

Methods (note: requires the current object self as input):

calc_bill inputs miles driven on rental (variable miles) and days rented (variable days)

Calculate bill as days times daily_rate (for trucks or self) plus miles * mile_rate

Provide/return bill as output

The purpose of the program 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.

fleet.text

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!