Please code in C++ and U can take time for this one and please follows all the instruction. Thank you so much. A. Create an abstract base class called Currency with two integer attributes, 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). The int attributes will represent whole part (or currency note value) and fractional part (or currency coin value) such that 100 fractional parts equals 1 whole part.  B. Create two derived classes - Dollar and Pound - with one additional non-public string attribute which will contain the name of the currency (Dollar or Pound) respectively. DO NOT add this attribute to the base Currency class. C. In your base Currency class, add public methods for the following, where appropriate (C++ students are allowed to use friend methods as long as a corresponding class method is defined as well): Default Construction (i.e. no parameters passed). Construction based on one single input of type double - create logical objects only, i.e. no negative value objects allowed. Copy Constructor and/or Assignment (i.e. the input is an object of the same class), as applicable to your programming language of choice. Destructor, as applicable to your programming language of choice. Setters and Getters for all attributes, as may be necessary. A method called add for adding an input object of the same currency. A method called subtract for subtracting an input object of the same currency - the result should be logical, i.e. negative results are not allowed. A method called isEqual for comparing an input object of the same currency for equality/inequality. A method called isGreater for comparing an input object of the same currency to identify which object is larger or smaller. A method called print to print the name and value of a currency object in the form "xx.yy" followed by the derived currency name, e.g. 1.23 Dollar or 2.46 Pound. All of the above should be instance methods and not static. The add and subtract as specified should manipulate the object on which they are invoked. It is allowed to have overloaded methods that create and return new objects. D. In your derived Dollar and Pound classes, add new methods or override inherited methods as necessary, taking care that code should not be duplicated or duplication minimized. Think modular and reusable code. E. Remember - Only the print method(s) in the classes should print anything to console, besides the main below. Throw String (or equivalent) exceptions from within the classes to ensure that invalid objects cannot be created. In all methods, ensure that you are not mixing objects of different currencies. F. In your main: Declare a primitive array of 2 Currency references (for C++ programmers, array of 2 Currency pointers). Set the first reference in the array to a Pound object and the second reference to a Dollar object, both of zero value. Then perform the sequence of operations as in the sample input/output below, understanding that your program will be tested with a different sequence of operations using the same patterns. All operations in the main should be performed on Currency objects demonstrating polymorphism.  Remember to handle exceptions appropriately. Sample input / output - remember my test program will follow the same pattern but not the same sequence:

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Please code in C++ and U can take time for this one and please follows all the instruction.

Thank you so much.

A. Create an abstract base class called Currency with two integer attributes, 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). The int attributes will represent whole part (or currency note value) and fractional part (or currency coin value) such that 100 fractional parts equals 1 whole part. 

B. Create two derived classes - Dollar and Pound - with one additional non-public string attribute which will contain the name of the currency (Dollar or Pound) respectively. DO NOT add this attribute to the base Currency class.

C. In your base Currency class, add public methods for the following, where appropriate (C++ students are allowed to use friend methods as long as a corresponding class method is defined as well):

  • Default Construction (i.e. no parameters passed).
  • Construction based on one single input of type double - create logical objects only, i.e. no negative value objects allowed.
  • Copy Constructor and/or Assignment (i.e. the input is an object of the same class), as applicable to your programming language of choice.
  • Destructor, as applicable to your programming language of choice.
  • Setters and Getters for all attributes, as may be necessary.
  • A method called add for adding an input object of the same currency.
  • A method called subtract for subtracting an input object of the same currency - the result should be logical, i.e. negative results are not allowed.
  • A method called isEqual for comparing an input object of the same currency for equality/inequality.
  • A method called isGreater for comparing an input object of the same currency to identify which object is larger or smaller.
  • A method called print to print the name and value of a currency object in the form "xx.yy" followed by the derived currency name, e.g. 1.23 Dollar or 2.46 Pound.
  • All of the above should be instance methods and not static.
  • The add and subtract as specified should manipulate the object on which they are invoked. It is allowed to have overloaded methods that create and return new objects.

D. In your derived Dollar and Pound classes, add new methods or override inherited methods as necessary, taking care that code should not be duplicated or duplication minimized. Think modular and reusable code.

E. Remember -

  • Only the print method(s) in the classes should print anything to console, besides the main below.
  • Throw String (or equivalent) exceptions from within the classes to ensure that invalid objects cannot be created.
  • In all methods, ensure that you are not mixing objects of different currencies.

F. In your main:

  • Declare a primitive array of 2 Currency references (for C++ programmers, array of 2 Currency pointers).
  • Set the first reference in the array to a Pound object and the second reference to a Dollar object, both of zero value.
  • Then perform the sequence of operations as in the sample input/output below, understanding that your program will be tested with a different sequence of operations using the same patterns.
  • All operations in the main should be performed on Currency objects demonstrating polymorphism. 
  • Remember to handle exceptions appropriately.
  • Sample input / output - remember my test program will follow the same pattern but not the same sequence:
**Table Explanation for Educational Website**

**Title: Understanding Currency Addition and Subtraction Through Event Sequencing**

This table demonstrates the process of handling financial transactions involving pounds and dollars through a sequence of events. Each action or operation updates the total currency values based on the type and amount of currency being manipulated.

**Columns:**

1. **Event Sequence**: This column describes the type of operation being performed at each step.
2. **Sample Input**: This column provides the command input symbolizing the action on the currency. 
   - The format is `a` for add or `s` for subtract, followed by the currency type `p` (pound) or `d` (dollar), and then the amount.
3. **Sample Output**: This column shows the resultant currency values in pounds and dollars after the operation.

**Rows Explanation:**

- **Program Starts**: Initializes the currency values at 0.00 Pound and 0.00 Dollar.
  
- **Add a pound object (a p 1.11 pound)**: Adds 1.11 pounds resulting in a balance of 1.11 Pound and 0.00 Dollar.

- **Add a dollar object (a d 12.12 dollar)**: Adds 12.12 dollars, updating the balance to 1.11 Pound and 12.12 Dollar.

- **Add a pound object (a d 3.45 pound)**: This operation returns an "Invalid addition" message, indicating an incorrect addition process, with balance remaining 1.11 Pound and 12.12 Dollar.

- **Add a dollar object (a d 0.13 dollar)**: Successfully adds 0.13 dollars, resulting in a balance of 1.11 Pound and 12.25 Dollar.

- **Subtract a dollar object (s d 10 dollar)**: Subtracts 10 dollars, updating the balance to 1.11 Pound and 2.25 Dollar.

- **Subtract a dollar object (s d 2.5 dollar)**: An "Invalid subtraction" is noted, implying an issue with the operation, leaving the balance unchanged at 1.11 Pound and 2.25 Dollar.

- **Subtract a pound object (s p 0.11 pound)**: Successfully subtracts 0.11 pounds, resulting in a final balance of 1.00 Pound and 2.25 Dollar.

This table serves as an example for
Transcribed Image Text:**Table Explanation for Educational Website** **Title: Understanding Currency Addition and Subtraction Through Event Sequencing** This table demonstrates the process of handling financial transactions involving pounds and dollars through a sequence of events. Each action or operation updates the total currency values based on the type and amount of currency being manipulated. **Columns:** 1. **Event Sequence**: This column describes the type of operation being performed at each step. 2. **Sample Input**: This column provides the command input symbolizing the action on the currency. - The format is `a` for add or `s` for subtract, followed by the currency type `p` (pound) or `d` (dollar), and then the amount. 3. **Sample Output**: This column shows the resultant currency values in pounds and dollars after the operation. **Rows Explanation:** - **Program Starts**: Initializes the currency values at 0.00 Pound and 0.00 Dollar. - **Add a pound object (a p 1.11 pound)**: Adds 1.11 pounds resulting in a balance of 1.11 Pound and 0.00 Dollar. - **Add a dollar object (a d 12.12 dollar)**: Adds 12.12 dollars, updating the balance to 1.11 Pound and 12.12 Dollar. - **Add a pound object (a d 3.45 pound)**: This operation returns an "Invalid addition" message, indicating an incorrect addition process, with balance remaining 1.11 Pound and 12.12 Dollar. - **Add a dollar object (a d 0.13 dollar)**: Successfully adds 0.13 dollars, resulting in a balance of 1.11 Pound and 12.25 Dollar. - **Subtract a dollar object (s d 10 dollar)**: Subtracts 10 dollars, updating the balance to 1.11 Pound and 2.25 Dollar. - **Subtract a dollar object (s d 2.5 dollar)**: An "Invalid subtraction" is noted, implying an issue with the operation, leaving the balance unchanged at 1.11 Pound and 2.25 Dollar. - **Subtract a pound object (s p 0.11 pound)**: Successfully subtracts 0.11 pounds, resulting in a final balance of 1.00 Pound and 2.25 Dollar. This table serves as an example for
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY