# Sparsh Pandey
# 15 Jun 2025
# Standard class example (with static variables and methods).
# Finished inheritance example

class Vehicle:
    
    def __init__(self, year, company, model, color, driver = None):
        self.year = year
        self.company = company
        self.model = model
        self.color = color
        self.driver = driver if driver is not None else "N/A"

    def __str__(self): 
        return "Your vehicle is a " + str(self.year) + " " + str(self.company) + " " + str(self.model)
 
    def drive(self, timeItTook, topSpeed):
        return timeItTook * topSpeed

    # Getters
    def getYear(self):
        return self.year

    def getCompany(self):
        return self.company

    def getModel(self):
        return self.model

    def getColor(self):
        return self.color

    def getDriver(self):
        return self.driver
 
    # Setters (we can't change the year, make, or model!)
    def setColor(self, newColor):
        self.color = newColor

    def setDriver(self, newDriver):
        self.driver = newDriver


# our car class, but we inherit from the vehicle class
class Car(Vehicle):
    def __init__(self, year, company, model, color, hp, driver=None):
        super().__init__(year, company, model, color, driver)
        self.hp = hp

    # The only one specific to cars. Getter and Setter for Horsepower (maybe you tuned your car)
    def getHP(self):
        return self.hp

    def setHP(self, newHP):
        self.hp = newHP

    # Note that we can use methods from the class we inherited from
    def __str__(self):
        return super().__str__() + " with " + str(self.hp) + " HP!"

    
# another class we made  
class Motorcycle(Vehicle):
    def __init__(self, year, company, model, color, cc, driver=None):
        super().__init__(year, company, model, color, driver)
        self.cc = cc

    # Same as car, this is specific only to bikes.
    def getCC(self):
        return self.cc

    def setCC(self, newCC):
        self.cc = newCC

    
    # It's quicker to use the one from vehicle, and then make some tweaks to the __str__ method in the car class!
    def __str__(self):
        return super().__str__() + " with " + str(self.cc) + " CC!"

    
def main():
    
    # make our car and bike (note how they're still vehicles).
    car1 = Car(1992, "Porsche", "964", "Yellow", 320, "Sparsh")
    bike1 = Motorcycle(2022, "Yamaha", "R1", "Blue", 998, "Zen")

    # print them out
    print(car1)
    print(bike1)
    
    # just make sure the getters work (you can try more if you want)
    print(car1.getDriver() + " owns the " + car1.getModel() + " in " + car1.getColor())
    print(bike1.getDriver() + " owns the " + bike1.getModel() + " in " + bike1.getColor())

    # set the HP and print it out
    car1.setHP(502)
    print(car1.getDriver() + " made tweaks to his vehicle. The " + car1.getModel() + " now has " + str(car1.getHP()) + " HP!")

    bike1.setCC(1002)
    print(bike1.getDriver() + " made tweaks to his vehicle. The " + bike1.getModel() + " now has " + str(bike1.getCC()) + " CC!")


main()
