Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Create a method called reallylonghex add public ReallyLongHex add(ReallyLongHex rightOp) { return null; } this is how much I have so far To help you
Create a method called reallylonghex add
public ReallyLongHex add(ReallyLongHex rightOp)
{
return null;
}
this is how much I have so far
To help you out with the assignment, we have implemented the methods above for you, with comments. See the code in ReallyLongHex.java. public ReallyLongHex add (ReallyLongHex rightop) Return a NEW ReallyLongHex that is the sum of the current ReallyLongHex and the parameter ReallyLongHex, without altering the original values. For example: ReallyLongHex X = new ReallyLongHex ("123456789"); ReallyLongHex Y = new ReallyLongHex ("987654321"); ReallyLongHex Z; z = x.add (Y); System . out.println(X + " + " + Y + " = " + Z); should produce the output: 0x1 2 3 4 5 6789 + 0x987654321 0xAAAAAAAAA = Be careful to handle carries correctly and to process the nodes in the correct order. Since the numbers are stored with the most significant digit at the beginning, the add) method can be implemented by first reversing the chains then traversing both chains in a systematic way. This must be done efficiently using references to traverse the lists. In other words, you should start at the beginning of each ReallyLongHex and traverse one time while doing the addition. The KEY is that for add) (and subtract) you should access each Node in the list only 1 time TOTAL. This is true for other methods as well. ThinkStep 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