title: Python -- Multiple Classes and Functions
body: <p>My objective is to create a python code that uses multiple classes and functions that creates a sort of index of different vehicle types and individual attributes for each vehicle. This is what I have so far, but I'm having a tough time with the inventory part where it actually displays all of the vehicles as well as the their attributes. Any advice or help?</p>
  
  <p><code>class Vehicle:</code></p>
  
  <pre><code>def __init__(self, make, model, year, mileage, price):
      self.__make = make
      self.__model = model
      self.__year = year
      self.__mileage = mileage
      self.__price = price
  
  def iMake(self, make):
      self.__make = make
  
  def iModel(self, model):
      self.__model = model
  
  def iYear(self, year):
      self.__year = year
  
  def iMileage(self, mileage):
      self.__mileage = mileage
  
  def iPrice(self, price):
      self.__price = price
  
  def getMake(self):
      return self.__make
  
  def getModel(self):
      return self.__model
  
  def getYear(self):
      return self.__year
  
  def getMileage(self):
      return self.__mileage
  
  def getPrice(self):
      return self.__price
  </code></pre>
  
  <p><code>class Car(Vehicle):</code></p>
  
  <pre><code>#number of doors
  def __init__(self, make, model, year, mileage, price, doors):
      Vehicle.__init__(self, make, model, year, mileage, price, doors)
      self.__doors = doors
  def iDoors(self, doors):   
      self.__doors = doors
  def gDoors(self):
      return self.__doors
  </code></pre>
  
  <p><code>class Truck(Vehicle):</code></p>
  
  <pre><code>#drive type (2 or 4 wheel drive)
  def __init__(self, make, model, year, mileage, price, drive):
      Vehicle.__init__(self, make, model, year, mileage, price, drive)
      self.__drive = drive
  def iDrive(self, drive):   
      self.__drive = drive
  def gDrive(self):
      return self.__drive
  </code></pre>
  
  <p><code>class SUV(Vehicle):</code></p>
  
  <pre><code>#passanger capacity
  def __init__(self, make, model, year, mileage, price, passengers):
      Vehicle.__init__(self, make, model, year, mileage, price, passengers)
  def capacity(self, passengers):
      self.__passengers = passengers
  def gCapacity(self):
      return self.__passengers
  </code></pre>
  
  <p><code>class Inventory:</code></p>
  
  <pre><code>def __init__(self, list1 = []):
      self.list1 = list1[:]
  def addVehicle(self, vehicle):
      self.list1.append(vehicle)
  def display(self):
      print("The inventory count is ", len(self.list1))
      for vehicle in self.list1:
          vehicle.display()
  </code></pre>
  
  <p><code>def main():</code></p>
  
  <pre><code>inventory = Inventory()
  classType = input('Is the vehicle a car, truck, or suv?  ')
  if classType == 'car':
      make = input('Please enter the make of the car: ')
      model = input('Please enter the model of the car: ') 
      year = input('Please enter the year of the car: ')
      mileage = input('Please enter the mileage of the car: ')
      price = input('Please enter the price of the car: ')
      doors = input('Please enter the amount of doors on the car: ')
      car = Car(make, model, year, mileage, price, doors)
      print('Make: ', car.gMake())
      print('Model: ', car.gModel())
      print('Year: ', car.gYear())
      print('Mileage: ', car.gMileage())
      print('Price: ', car.gPrice())
      print('Number of doors: ', car.gDoors())
      print()
  elif classType == 'truck':
      make = input('Please enter the make of the truck: ')
      model = input('Please enter the model of the truck: ') 
      year = input('Please enter the year of the truck: ')
      mileage = input('Please enter the mileage of the truck: ')
      price = input('Please enter the price of the truck: ')
      drive = input('Please enter 2 wheel or 4 wheel drive for the truck: ')
      truck = Truck(make, model, year, mileage, price, drive)
      print('Make: ', truck.gMake())
      print('Model: ', truck.gModel())
      print('Year: ', truck.gYear())
      print('Mileage: ', truck.gMileage())
      print('Price: ', truck.gPrice())
      print('Type of drive: ', truck.gDrive())
      print()
  elif classType == 'suv':
      make = input('Please enter the make of the suv: ')
      model = input('Please enter the model of the suv: ') 
      year = input('Please enter the year of the suv: ')
      mileage = input('Please enter the mileage of the suv: ')
      price = input('Please enter the price of the suv: ')
      passengers = input('Please enter the capacity of the suv: ')
      suv = SUV(make, model, year, mileage, price, drive)
      print('Make: ', suv.gMake())
      print('Model: ', suv.gModel())
      print('Year: ', suv.gYear())
      print('Mileage: ', suv.gMileage())
      print('Price: ', suv.gPrice())
      print('Number of passengers: ', suv.gCapacity())
      print()
  cont = input('Would you like to add another vehicle?  y/n  ')
  if cont == 'y':
      main()
  elif cont == 'n':
      inventory.display()
  </code></pre>