Hey everyone was wondering if I could get some help with a method (compareTo) in my class (InfiniteInt). I know my logic is not 100% right so I was wanting a push in the right direction. The nodes used are from a Doubly Linked List which InfiniteInt is a subclass from. (dont want to put too much of my code on here so if that is something you need I can put it). Thank you for your time/help!
I guess it would help if I told you what was wrong... The first two cases, less than and greater than are working. The only one not working is if they are equal. I am not getting a 0 but instead a -1.
Here's what I notice: lines 19 to 33 always return some value, one of 1 or -1 or zero. That means that lines 34 to 39 can never be executed.
So I'm guessing you meant to put 34 to 39 somewhere else. If your InfiniteInt class is supposed to act like holding an integer with its digits in a linked list, then probably you meant to put them before line 19. I don't think that would solve everything but it would likely be a step forward.
However to me it looks like your code would get a 0 when you compare 1-9-4-9 to 1-6-7-8, rather than the correct value of -1. But you say you have the opposite problem? Then some debugging would help find out what's going on.
Thank you Paul! I was going to start putting in a bunch of S.O.Pln but thought I would post on here first to see if something was compltely messed up first (I often overlook "little" things)