CST8132_Lab4_BankAccountPolymorphism.pdf - CST8132 Object...

This preview shows page 1 - 2 out of 3 pages.

CST8132 Object Oriented Programming Lab 4: Bank Account Polymorphism Due: Start of Lab Sessions in Week 5 Purpose This is an exercise to practice with the concept of Polymorphism. Suggested Reading: Chapters 9, 10 of Deitel and Deitel. Description This is a polymorphism example, so right from the start we know we will be processing items of a type that is a super-class (maybe abstract) or an interface. Remember the "type" is the word that goes on the left side when we declare a variable (examples, int, Shape, Animal, Vehicle, double, String, etc - but only the ones with capital letters are reference types that can be used with polymorphic processing). The super-class or interface tells us about the list of behaviors of the objects we need to process. We've seen the super-classes Shapein the past. When we say "behavior", we mean the methods that will be available for us to use, even though the specifics, the actual implementation, of those methods, can be determined by the sub-class. For example, the Shapesuperclass tells us what all shapes can do: give their area. The specific shapes each calculate their area differently. In this case for this exercise we have bank accounts. What methods would all bank accounts have? calculateInterest? deposit? withdraw? getBalance? calculateAndUpdateBalance? What kinds of bank accounts are there? Chequing, Savings, Investment, Credit Card? As programmers by now we have been trained to recognize that there can be some methods that

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture