Answered You can hire a professional tutor to get the answer.
Can you please right me down the steps to follow to get this code working?
Can you please right me down the steps to follow to get this code working? Step by step please.
Question:
Need a final program that meets the requirements outlined below.
Need 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
Here is the code
class Automobile:
def __init__(self, make, model, color, year, mileage):
self._make = make
self._model = model
self._color = color
self._year = year
self._mileage = mileage
def getMake(self):
return self._make
def getModel(self):
return self._model
def getColor(self):
return self._color
def getYear(self):
return self._year
def getMileage(self):
return self._mileage
def setMake(self, m):
self._make = m
def setModel(self, m):
self._model = m
def setColor(self, m):
self._color = m
def setYear(self, m):
self._year = m
def setMileage(self, m):
self._mileage = m
#method to add new vehicle to the list
def addVehicle(lstVehicle, vehicle):
lstVehicle.append(vehicle)
return lstVehicle
#method to remove vehicle from the list
def removeVehicle(lstVehicle,vehicle):
lstVehicle.remove(vehicle)
return lstVehicle
#method to update the vehicle in the list
def updateVehicle(lstVehicle,vehicle):
for obj in lstVehicle:
if obj.getMake() == vehicle.getMake():
obj.setColor("Red")
return lstVehicle
def main():
vehicle = Automobile("Test","","",2018,23) #create new vehicle
vehicle1 = Automobile("Test1","","",2018,12) #create new vehicle
vehicle2 = Automobile("Test2","","",2018,14)#create new vehicle
lstVehicles=[] #delcare a list for vehivles
#add vehicle to list
addVehicle(lstVehicles,vehicle)
addVehicle(lstVehicles,vehicle1)
addVehicle(lstVehicles,vehicle2)
#remove the vehicle
removeVehicle(lstVehicles,vehicle)
vehicle2 = Automobile("Test1","Black","",2018,23)
#update the vehicle in list
updateVehicle(lstVehicles, vehicle2)
#open a new file to write
thefile = open('test.txt', 'w')
for item in lstVehicles:
#print the output to console
print(item.getMake()+" "+ item.getColor())
#write the list items to the file
thefile.write("%sn" % item.getMake()+" "+ item.getColor()) #you can add additional fileds yourself
)
main()