For this homework assignment, submit a copy of
hwkPolymorphism.cpp.
First of all, list the four essential ingredients for having a polymorphic method call in the multi-line comment at the top of the
.cpp file.
Next, add
four classes, all in the
hwkPolymorphism.cpp.
Start by adding an
abstract base class named
Account.
Choose the method to make it an abstract base class wisely.
Additionally, add a
SavingsAccount, a
CheckingAccount, and a
CDAccount each of which inherits from
Account.
Make sure you put the common private data members and member methods in
Account.
Label the code (including in
main()) with comments where each of the four ingredients is manifest.
Additionally, add a comment indicating the polymorphic call.
For full points, do not make changes (except for adding comments) to the body of the
main() function.
Your copy needs to compile on
ranger using the following command-line:
g++ -std=c++0x hwkPolymorphism.cpp
Finally, when your code is executed, the output must match what's in
hwkPolymorphism-stdout.txt exactly:
(Bank account index 0)
Savings Account Information:
Balance: $222.21
Interest rate: 1.2%
(Bank account index 1)
Checking Account Information:
Balance: $5.69
Last check number processed: 234
(Bank account index 2)
CD Account Information:
Balance: $5000
Interest rate: 2.5%
Maturity: 6 months
Submission
Submit your cpp file at
https://3110.cs.mtsu.edu/. For further instructions, please see the
Miscellaneous page.
Rubric:
Points Item
---------- --------------------------------------------------------------
_____ / 1 Four essential ingredients for having a polymorphic method call
_____ / 2 Class Account (abstract base class)
_____ / 1 Class SavingsAccount
_____ / 1 Class CheckingAccount
_____ / 1 Class CDAccount
_____ / 1 Comments indicating the four essential ingredients
_____ / 1 Comments indicating the polymorphic call
_____ / 8 Total