python code issues
I am working on a project and have most of it completed, I am having issues with a few items, I have added my issues as comments in the code
class Automobile:
vehicle_list = []
def __init__(self, year, make, model, color, mileage):
self.__year = year
self.__make = make
self.__model = model
self.__color = color
self.__mileage = mileage
Automobile.vehicle_list.append(self)
def add_new_vehicle(VIN):
Automobile.vehicle_list.append(VIN)
def remove_vehicle(VIN):
for vehicle in Automobile.vehicle_list:
if vehicle.get_make()==VIN:
Automobile.vehicle_list.remove(VIN)
def remove_vehicle(self):
if self in Automobile.vehicle_list:
Automobile.vehicle_list.remove(self)
self = None
def get_year(self):
return self.__year
def get_make(self):
return self.__make
def get_model(self):
return self.__model
def get_color(self):
return self.__color
def get_mileage(self):
return self.__mileage
def set_year(self, value):
self.__year = value
def set_make(self, value):
self.__make = value
def set_model(self, value):
self.__model = value
def set_color(self, value):
self.__color = value
def set_mileage(self, value):
self.__mileage = value
def __str__(self):
return ” year: ” + str(self.get_year()) +”vehicle make: ” + str(self.get_make()) + ” model: ” + str(self.get_model()) + ” color: ” + str(self.get_color()) + ” mileage: ” + str(self.get_mileage())
def menu():
print(“What would you like to do?”)
print(“1. Enter a new vehicle”)
print(“2. Delete a current vehicle”)
print(“3. Exit”)
choice=input(“Please Enter a Selection 1-3: “)
return choice
def main():
while True:
choice=int(menu())
if choice==1:
VIN=input(“Enter vehicle VIN: “)
year=int(input(“Enter vehicle year: “)) #need to add exception #need to add a way to update the vehicles info for each category
make=input(“Enter vehicle make: “) #need to add a way to update the vehicles info for each category
model=input(“Enter vehicle model: “) #need to add a way to update the vehicles info for each category
color=input(“Enter vehicle color: “)#need to add a way to update the vehicles info for each category
mileage=int(input(“Enter vehicle mileage: “)) #need to add exception #need to add a way to update the vehicles info for each category
print(“Vehicle Entered”)
print(‘n’)
vehicle = Automobile(VIN, model, color, year, mileage)
elif choice==2:
VIN=input(“Enter vehicle VIN: “)
Automobile.remove_vehicle(VIN)
print(“Vehicle Removed”)
print(‘n’)
elif choice==3:
break
main()
file = open(“inventory.txt”, “w”) # is this set up correctly to allow the user to output all vehicle inventory to a text file?
for v in Automobile.vehicle_list:
file.write(str(v) + “n”)
Do you need a similar assignment done for you from scratch? We have qualified writers to help you. We assure you an A+ quality paper that is free from plagiarism. Order now for an Amazing Discount!
Use Discount Code “Newclient” for a 15% Discount!
NB: We do not resell papers. Upon ordering, we do an original paper exclusively for you.
The post python code issues appeared first on Custom Nursing Help.