Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a PYTHON program that meets the requirements outlined below. Create an au

ID: 3920760 • Letter: C

Question

Create a PYTHON program that meets the requirements outlined below.

Create an automobile class that will be used by a dealership as a vehicle inventory program. The following attributes should be present in your automobile class:

private string make

private string model

private string color

private int year

private int mileage

Your program should have appropriate methods such as:

constructor

add a new vehicle

remove a vehicle

update vehicle attributes

At the end of your program, it should allow the user to output all vehicle inventory to a text file.

Explanation / Answer

Answer:

class Auto_class:

def __init__(self):
self.make = " "
self.model = " "
self.color = " "
self.year = 0
self.mileage = 0


def add_vehicle(self):
self.year = int(input("Please enter year: "))
self.make = input("Please enter make: ")
self.model = input("Please enter model: ")
self.color = input("Please enter color: ")
self.mileage = int(input("Please enter mileage: "))

def __str__(self):
return('%d %s %s Color: %s Mileage: %d' %
(self.year, self.make, self.model, self. color,
self.mileage))

vehicle_list = []

def edit(vehicle_list):
pos = int(input('Enter the position of the vehicle to edit: '))
new_vehicle = car.add_vehicle()
new_vehicle = car.__str__()
vehicle_list[pos-1] = new_vehicle
print('Vehicle was updated')

user=True
while user:
print ("""
1.Add a Vehicle
2.Delete a Vehicle
3.View Inventory
4.Update Inventory
5.Output all Vehicle Inventory
6.Quit
""")
ans=input("What would you like to do? ")
if ans=="1":
car = Auto_class()
car.add_vehicle()
vehicle_list.append(car.__str__())

elif ans=="2":
for i in vehicle_list:
vehicle_list.pop(int(input('Enter position of vehicle to remove: ')))
print('Successfully removed vehicle')
elif ans=="3":
print(vehicle_list)
elif ans=="4":
edit(vehicle_list)
elif ans=='5':
f = open('vehicle_inv.txt', 'w')
f.write(str(vehicle_list))
f.close()
else:
print('try again')