Project includes: HugeInteger_YI.java and HugeIntegerDriver_YI.java
Huge Integer Class: Create a class HugeInteger which uses a 40-element array of digits to store integers as large as 40 digit long. Provide methods parse, toString, add and subtract to manipulate objects of HugeInteger. Method parse should receive a String, extract each digit using method charAt or substring and place the integer equivalent of each digit into the integer array and return a HugeInteger object. For comparing HugeInteger objects, provide the following methods:
isEqualTo, isGreaterThan, isLessThan, isGreaterThanOrEqualTo and isLessThanOrEqualTo
Each of these is a predicate method that returns true if the relationship holds between the two HugeInteger objects and returns false if the relationship does not hold. Provide a predicate method isZero.
The driver should look like this:
…
// 40-digit input
HugeInteger hi1 = new HugeInteger(?); // where the ? means any implementation you choose
HugeInteger hi2 = new HugeInteger(?); // where the ? means any implementation you choose
…
Addition implementations could be as follows:
HugeInteger hi3 = hi2.subtract(hi1);
or
hi2.subtract(hi1)
Things to know:
* Your driver should accept input BUT for testing purposes ONLY, you should hard code the test data.
* Do not use more than 10 digits as test data.
* Assume the string contains only integers.
Make sure you test your code properly:
– add numbers that require carryover
– subtract numbers that require borrowing
– a HugeInteger can be negative
– print the numbers before and after the operations
**** NOTE: This assignment is about object-oriented design. Therefore, the operands are objects of HugeInteger.
Before you start on this assignment, read it carefully and turn your paper for approval:
1. Simple example in paper and pencil: choose two smaller than 40-digit numbers and using your design add and subtract them. Use a diagram representing how the digits are placed in the array.
2. Address the details you need to implement to handle any issues like a “carry-over” and “borrowing” that might arise: re-design.
3. Re-do the example after you make the changes to your design.
NOTE: If you have any questions, I will not answer them unless you have your example on paper.
.
.
.
BE AWARE that
25% of the grade is based on documentation. Indicate with a comment the code that handles each operation and how it does it.
25% of the grade is based on thorough testing.
25% of the grade is based on well-organized and readable code
25% of the grade is based on the working code.
Extra credit: provide methods multiply, divide and remainder. Limit these last 3 operations by a data type int.