Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.

QUESTION

Hello, I need to develop an automobile class that will be used by a dealership as a vehicle inventory program. The following attributes should be...

Hello,

I need to develop an automobile class that will be used by a dealership as a vehicle inventory program. The following attributes should be present: Private string make, model, color, int year, and int mileage. The program needs a constructor, add new vehicle, remove vehicle, update vehicle attributes

Below is the code that I have had help on but when ran it is stating I need to define vehicle.Please help. Thank you

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 set_make(self, m):

  self._make= m

def set_model(self, m):

  self._model = m

def set_color(self, m):

  self._color = m

def set_year(self, m):

  self._year = m

def set_mileage(self, m):

  self._mileage = m

def get_make(self):

  return self._make

def get_model(self):

  return self._model

def get_color(self):

  return self._color

def get_year(self):

  return self._year

def get_mileage(self):

  return self._mileage

vehicles = [ ]

def add_vehicle(vehicle):

    global vehicles

    vehicles.append(vehicle)

def remove_vehicle(make):

    for i in range(len(vehciles)):

      if vehicles[i].get_make( ) == make:

        del vehciles[i]

def update_vehicle(index, make, model, color, year, mileage):

    global vehicles

    v = vehicles[index]

    v.set_make(make)

    v.set_model(model)

    v.set_color(color)

    v.set_year(mileage)

def write_file( ):

    file = open ('vehicles.txt', 'k')

    for a in vehicles:

      file.write(a)

      file.write('n')

    file.close( )

def main( ):

  menu = { }

  menu ['1'] = 'Add vehicle'

  menu ['2']= 'Remove vehicle'

  menu ['3'] = 'Find Vehicle'

  menu ['4'] = 'Quit/Exit'

user = True

while user:

  print("""

  1. Add vehicle

  2. Remove vehicle

  3. Find vehicle

  4. Quit/Exit

  """)

  ans= input('Choose options, 1. to add a vehicle, 2. to remove a vehicle, 3. to find a vehicle, or 4. to quit/exit. ')

  if ans == '1':

    vehicle.add_vehicle

  elif ans == '2':

    vehicle.remove_vehicle

  elif ans == '3':

    print('Automobile.vehicle')

  elif ans == '4':

    print ('Goodbye')

  elif ans != '':

    print('Invalid entry')

if __name__ == '__main__':

  main ( )

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question