title: Polymorphism and Classes in Python
body: <p><a href="https://i.stack.imgur.com/JeZjm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JeZjm.png" alt="enter image description here"></a>I am having trouble completing this assignment for school. This picture is what the output should be when complete.</p>
  
  <p>Here is the problem I am tasked with:</p>
  
  <p>"In the main.py file creates four objects. (vehicle, sedan, truck, hatchback)
  The main.py should have a main function and a function to display the contents of each object. It should also use the <code>isinstance</code> function to test for valid data (Tennis shoes is not a vehicle!)
  In the vehicle.py file create a superclass called Automobile and three subclasses (sedan, truck, and hatchback)
  The Automobile class should have three attributes (make,engine_type and drive_type. Figure 2 shows the values for these attributes as Basic Sedan, 6 cylinders, Front Wheel.
  Sedan subclass should inherit the Automobile class and override the engine type.
  Truck and hatchback subclasses should inherit the Automobile class and override both the engine type and drive type."</p>
  
  <p><strong>Here is my classes file named vehicles</strong></p>
  
  <pre><code>    #create a superclass named Automobile
  class Automobile:
  
      #the __init__method accepts an argument for the automobiles make
  
      def __init__(self, make, engine_type, drive_type):
          self.__make = make
          self.__engine_type = engine_type
          self.__drive_type = drive_type
  
      def show_make(self):
          print('Automobile Make:', self.__make)
  
      def show_drive_type(self):
          print(self.__drive_type)
  
      def show_engine_type(self):
          print(self.__engine_type)
  
  
  
  class Sedan(Automobile):
  
      def __init__(self, make, engine_type, drive_type):
          Automobile.__init__(self, make, engine_type, drive_type)
  
      def engine_type(self):
          print('4 cylinder')
  
      def drive_type(self):
          Automobile.__init__(self)
  
  
  class Truck(Automobile):
  
      def __init__(self, make, engine_type, drive_type):
          Automobile.__init__(self, make, engine_type, drive_type)
  
      def engine_type(self):
          print('8 cylinder')
  
      def drive_type(self):
          print('Four Wheel')
  
  
  class Hatchback(Automobile):
  
      def __init__(self, make, engine_type, drive_type):
          Automobile.__init__(self, make, engine_type, drive_type)
  
      def engine_type(self):
          print('Electric')
  
      def drive_type(self):
          print('All Wheel')
  </code></pre>
  
  <p><strong>And here is my main file with my main function inside</strong></p>
  
  <pre><code>#import the vehicles file with classes
  import vehicles
  
  #define the main function
  def main():
      #create an Automobile object, and all subclass objects
      automobile = vehicles.Automobile('Sedan', '6 Cylinder', 'Front Wheel')
      sedan = vehicles.Sedan()
      truck = vehicles.Truck()
      hatchback = vehicles.Hatchback()
  
  
  
      #display information about each one
      print('Here are some vehicles and their engine types.')
      print()
      show_auto_info(automobile)
      print()
      show_auto_info(sedan)
      print()
      show_auto_info(truck)
      print()
      show_auto_info(hatchback)
      print()
      show_auto_info('Tennis Shoes')
  
  #define the show_auto_info function
  def show_auto_info(car):
      if isinstance(car, vehicles.Automobile):
          car.show_make()
          car.show_drive_type()
          car.show_engine_type()
      else:
          print(car, 'is not a vehicle!')
  
  
  
  main()
  </code></pre>
  
  <p>This is the error that i'm getting:
     <code>Automobile.__init__(self)
  TypeError: __init__() missing 3 required positional arguments: 'make', 'engine_type', and 'drive_type'</code></p>
  
  <p>Process finished with exit code 1</p>