Question
A. Create an abstract Dollar class with two integer attributes, both of which are non-public (Python programmers - it is understood that there is nothing
A. Create anabstractDollarclass withtwointegerattributes, both of which are non-public (Python programmers - it is understood that there is nothing private in Python but try to not access the attributes directly from outside the classes). Theintattributes will represent the whole part (or currency note value) and a fractional part (or currency coin value) such that 100 fractional parts equal 1 whole part.
B. Create three derived classes -USD,CAD,andAUD-each withoneadditional non-publicstringattribute which will contain the name of the country - USA, Canada, and Australia respectively.
C. In your currency classes, add public methods for the following, where appropriate:
- Default Construction (i.e. no parameters passed)
- Construction based on parameters for all attributes
- Copy Constructor and/or Assignment,as applicable to your programming language of choice
- Destructor,as applicable to your programming language of choice
- Setters and Getters for all attributes
- Adding two objects of the same currency
- Subtracting one object from another object of the same currency
- Comparing two objects of the same currency for equality/inequality
- Comparing two objects of the same currency to identify which object is larger or smaller
- Print method to print details of a currency object
D. Create aWalletclass with one attribute - an array of threeDollarreferences/pointers and the following methods to demonstrate polymorphism of the currencies:
- A default Constructor which sets
- the first element of the array to a zero value USD object
- the second element of the array to a zero value CAD object
- the third element of the array to a zero value of AUD object
- A Destructor,as applicable to your programming language of choice
- Methods to add or subtract currency objects appropriately usingDollarreferences/pointers, i.e.
- USD objects to/from the first element only,
- CAD objects to/from the second element only and
- AUD objects to/from the third element.
- Do not write currency-specific add/subtract methods in the Wallet as that would defeat the purpose of polymorphism.
- Methods to compare if the value of either element is greater or smaller than an input value usingDollarreferences only. This method can be called upon in the subtract method above as needed.
- A method to Print the values of the three elements in the Wallet
E. In your main:
- Create a Wallet object
- Provide the user the main menu to add/ subtract/ compare the USD, CAD, and AUD values in the Wallet as well as print the contents of the Wallet
- You can use a second-level menu choice to allow the user to select currency type
- Based on user choice, create either USD, CAD, AUD objects as needed to perform the desired operations.
- The main menu should be run in a loop until the user selects the Exit option
- There is no sample output - you are allowed to provide user interactivity as you see fit and programs will be graded for clarity of interaction
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started