Objects are mutable this is an alias and may be a

Info icon This preview shows pages 2–4. Sign up to view the full content.

# Objects are mutable # This is an alias and may be a good idea self.owner = owner def getOwner(self) return self.owner def setOwner(self, owner) self.owner = owner def __str__(self) return ( Registration Number {}n Owner {}.format(self.__idNumber, self.owner)) # This is a subclass (or derived class) class Car( Vehicle) def __init__(self, numDoors, owner=None) # Calling super class constructor to initialize the super class object Vehicle.__init__(self, owner) self.numDoors = numDoors def getNumDoors(self) return self.numDoors def __str__(self) return ({} n Type Car n Number of doors {} .format(Vehicle.__str__(self), self.numDoors)) # This is a subclass (or derived class) class Truck( Vehicle) def __init__(self, numAxles, owner=None) # Calling super class constructor to initialize the super class object # A different way - Becomes less explicit with more than one level of inheritance andor # multiple inheritance super().__init__(owner) self.numAxles = numAxles def getNumAxles(self) return self.numAxles def __str__(self) return ({} n Type Truck n Number of axles {}.format(super().__str__(), self.numAxles)) # This is a subclass (or derived class) class Motorcycle( Vehicle) def __init__(self, hasSidecar, owner=None) Vehicle.__init__(self, owner) self.hasSidecar = hasSidecar def setHasSidecar(self, hasSidecar)
Image of page 2

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

self.hasSidecar = hasSidecar def getHasSidecar(self) return self.hasSidecar def __str__(self) return ({} n
Image of page 3
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern