View the step-by-step solution to:

When the code opens, nothing happens. class Automobile():

I need help coming up with a main() method where I can expect a user prompt for this code. When the code opens, nothing happens. any help would be appreciated.

class Automobile():

  __make = ""

  __model = ""

  __color = ""

  __year = 0

  __mileage = 0



  def __init__(self, make = None, model = None, color = None, year = None, mileage = None):

    self.make = make

    self.model = model

    self.color = color

    self.year = year

    self.mileage = mileage

  def add_vehicle(self):

    auto = Automobile()

    vehicle_file = open('vehicle.txt', 'a')

    make = input("Enter make: ")

    model = input("Enter model: ")

    color = input("Enter color: ")

    year = input("Enter year: ")

    mileage = input("Enter mileage: ")


    vehicles = Automobile(make, model, color, year, mileage)

    vehicle_list = [vehicles.make, vehicles.model, vehicles.color, vehicles.year, vehicles.mileage]


    for item in vehicle_list:

      vehicle_file.write("%st" % item)



    print("Added to the inventory")


  def delete_vehicle(self):

    del_rec = input("Enter record to delete: ")


    with open("vehicle.txt","r+") as f:

      new_f = f.readlines()

      for line in new_f:

        if del_rec not in line:



    print("Succesfully deleted")


  def set_make(self, make):

    self.make = make

  def get_make(self):

    return self.make

  def set_model(self, model):

    self.model = model

  def get_model(self):

    return self.model

  def set_color(self, color):

    self.color = color

  def get_color(self):

    return self.color

  def set_year(self, year):

    self.year = year

  def get_year(self):

    return self.year

  def set_mileage(self, mileage):

    self.mileage = mileage

  def get_mileage(self):

    return self.mileage

Top Answer

Your class is well defined. When you open the code and nothing happens because there is no main method defined, you can write... View the full answer

Sign up to view the full answer

Other Answers

Output screen looks like: Enter make: abc Enter model: xyz Enter... View the full answer




Why Join Course Hero?

Course Hero has all the homework and study help you need to succeed! We’ve got course-specific notes, study guides, and practice tests along with expert tutors.


Educational Resources
  • -

    Study Documents

    Find the best study resources around, tagged to your specific courses. Share your own to gain free Course Hero access.

    Browse Documents
  • -

    Question & Answers

    Get one-on-one homework help from our expert tutors—available online 24/7. Ask your own questions or browse existing Q&A threads. Satisfaction guaranteed!

    Ask a Question
Ask a homework question - tutors are online