# Author: James Tam # Version: June 10, 2024 # Learning: # *A program with multiple classes # *Automatically calling a str method (passing object/reference to print) from Vehicle import Vehicle class Person: def __init__(self,newName,newAge): self.name = newName self.age = newAge self.vehicle = None self.partner = None def haveBirthday(self): print("Happy Birthday!") self.mature() def mature(self): self.age = self.age + 1 #Returns the current state of the object #Automatically called when object/reference is passed to print def __str__(self): objectState = "Person information\n" objectState = objectState + "Name: " +self.name objectState = objectState + "\t\tAge: " +str(self.age) if not(self.vehicle is None): objectState = objectState +"\t\tMy partner: " + self.partner.name if not(self.vehicle is None): objectState = objectState + "\nVehicle information\n" +self.vehicle.__str__() return(objectState) """ Test code p = Person("JT",37) p2 = Person("Stacey",22) p.partner = p2 p.vehicle = Vehicle() print(p) print() print(p2) """