# Created by PyCharm Pro Edition    
# User: Kaushik Talukdar                   
# Date: 24-04-17                           
# Time: 12:29 AM

# INHERITANCE
# We can create a new class, but instead of writing it from scratch, we can base it on an existing class.

# Lets understand inheritance better with an example

class Car():
    def __init__(self, make, model, year):
        self.make = make
        self.model = model
        self.year = year
        self.mileage = 0

    def get_descriptive_name(self):
        full_name = self.make.title() + ' ' + self.model.title() + ' ' + str(self.year)
        return full_name

    def update_odometer(self, mileage):
        self.mileage = mileage


# the class below is an inherited class derived from Cars and have access to Car's variables as well as methods
# The parent class name must appear in parenthesis in child class for Inheritance to work

# the super() method is responsible for providing the child class with all the variables and methods of parent class

class ElectricCar(Car):
    def __init__(self, make, model, year):
        super().__init__(make, model, year)


my_car = ElectricCar('Tesla', 'Model S', '2017')
car = my_car.get_descriptive_name()
print(car)
