Need it in an hour please. Make sure it outputs all vehicle inventory to a text
ID: 3920735 • Letter: N
Question
Need it in an hour please. Make sure it outputs all vehicle inventory to a text file.
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
class AutoMobile :
_aAutomobiles= [];
def _init_(newautomobile,make,model,color,year,mileage):
newautomobile.make = make;
newautomobile.mileage = mileage;
newautomobile.color = color;
newautomobile.year = year;
newautomobile.model = model;
def addAutoMobile(newautomobile):
AutoMobile._aAutomobiles.append(newautomobile);
def removeAutoMobile(oldAutoMobile):
AutoMobile._aAutomobiles.remove(oldAutoMobile);
def updateAutomobile(oldAutoMobile,propertyToBeUpdated, propertyValue):
for vechile in AutoMobile._aAutomobiles:
if(vechile.propertyToBeUpdated == oldAutoMobile.propertyToBeUpdated):
vechile.propertyToBeUpdated = propertyValue;
def printAutoMobileInFile() :
outputFile = open("outputFile.txt",w);
for vehicle in AutoMobile._aAutomobiles:
print ("Model=",vehicle.model,"Mileage=",vehicle.mileage,"Make=",vehicle.make,"color=",vehicle.color,"Year=",vehicle.year);
outputFile.close();
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.