C++ CSIS211 Data Structures -- 2

Job ID: 34422282

Budget: $15 – $25 USD

Submit an informal design that shows how your classes for the project are going to be constructed. An informal design for this class is nothing more than your class definitions along with prototypes for the class members.
In Step 1, you created a class called Char that would do a few things with a char primitive type. In this assignment we are going to use the Char class to create another class called BigDecimal. What this means is that you are going to store digit characters in your Char class and then add new instances of the Char class to create a BigDecimal.

The BigDecimal class is going to need a way to hold all of the Char classes that you add to it so you might want to consider using a vector. I realize that the vector class in Java is somewhat going away so if you are using Java you might want to consider using the ArrayList. From this point forward I will refer to ArrayList and vector as a container. This way I don't have to keep typing both.

Your BigDecimal class should have the following constructors

BigDecimal() - default constructor should simply set your container to three Char objects that contain the values '0' '.' '0'
BigDecimal(String value) - This constructor will parse the string taking each digit, putting it into a new Char and adding the Char to the container.
Your BigDecimal class should also contain the following mutators

void setValue(char ch) - A char that contains a digit
void setValue(String value) - This does the same as the overloaded constructor that takes a string
BigDecimal add(BigDecimal) - Adds the values together and returns the result as a Big Decimal
BigDecimal sub(BigDecimal) - Subtracts the two values and returns the result as a BigDecimal
Note: If you are using C++ feel free to use the + operator instead of the add function.

I am going to let you off the hook for the multiply and divide but it should be easy to implement.

Accessors

double toDouble() - Returns the value stored in the container as a double
String toString() - Returns the value store in the container as a string
Char at(int index ) - Returns the value at the particular index as a Char
Caveat:

If you are using C++ your container must hold pointers to the Char type. This means when you push something back you need to do the following:

v.push_back(new Char('A'));