3. Operations declaration and inheritance

3.1. Client Class and Improved Account Class

3.1.1. Using the Client and Improved Account Classes

3.2. Inheritance

  • Object inheritance allows us to modify our classes by adding or modifying attributes and methods based on the previous class.

  • We will create special accounts where we can withdraw more money than the balance, up to a certain limit.

  • Deposit, withdrawal, and summary operations continue as a regular account.

3.3. Special Account Class

  • Note that we wrote Account in parentheses.

  • SpecialAccount inherits the methods and attributes of Account.

  • self.limit will only be created for classes of type SpecialAccount.

  • Note that we are completely overriding the withdraw method in SpecialAccount.

3.4. Advantages of Inheritance

  • We have made minimal changes to our program, maintaining previous functionality and adding new features.

  • It was possible to reuse account methods.

  • Therefore, the definition of the SpecialAccount class was much simpler, including only the different behavior.

3.5. Using all classes

You have attempted of activities on this page