It seems like you would have to do a few things to compare two Infinite Integers.
1. Does one have more nodes than the other? If so, the one with more nodes is greater, since each node holds 3 numbers.
2. Do they have the same number of nodes? If so, start at the top node for each, and compare the numbers. If one node's integers are greater than the other's, the greater one is your answer. Otherwise, move on to the second node (for each Infinite Integer)
It doesn't seem to me that your code is doing these things.
BestJewSinceJC
Posting Maven
2,772 posts since Sep 2008
Reputation Points: 874
Solved Threads: 354
So that should tell you something. A node and an Integer are not the same data type so you shouldn't be trying to force them to be.
BestJewSinceJC
Posting Maven
2,772 posts since Sep 2008
Reputation Points: 874
Solved Threads: 354
You can use Integer.parseInt(yourString) to convert a String to an Integer. But I'd recommend you think about my advice earlier. . I don't think there is an easier way to accomplish your goal.
BestJewSinceJC
Posting Maven
2,772 posts since Sep 2008
Reputation Points: 874
Solved Threads: 354
It's hard to say because I don't know what your class looks like for Infinite Int
BestJewSinceJC
Posting Maven
2,772 posts since Sep 2008
Reputation Points: 874
Solved Threads: 354
If you're still asking for help with your question, "Ok I tried a couple of stuff but I'm at a loss here, I'm not sure how to check if the node data is less than 10 so I can add "00" to the string without forcing it, any tips would be appreciated", you're going to need to post the DLList class. Your InfiniteInt class extends DLList, but how am I going to tell you how to check the data without knowing what type of Object the data is, which requires seeing the DLList class? If the "data" Object that you keep referring to is simply a String, then use what I told you above.
BestJewSinceJC
Posting Maven
2,772 posts since Sep 2008
Reputation Points: 874
Solved Threads: 354
Don't use generics for your InfiniteInt class; it will *always* be a DLL of type Integer [or in general Number]. Instead create your InifiniteInt class by extending the DLL class and specifying Integer as the type parameter.
class DLL<T> {
// A DLL of objects of type T
}
class Infinite extends DLL<Integer> {
// integers expressed as DLL of Integer objects
}
Also, how do you propose to handle negative integers?
~s.o.s~
Failure as a human
11,938 posts since Jun 2006
Reputation Points: 3,281
Solved Threads: 734