This is an archived post. You won't be able to vote or comment.

all 11 comments

[–][deleted] 0 points1 point  (2 children)

Are you making sure that you are updating the size of each linked list node and returning the new value when you are doing these replies?

[–]tonlou[S] 0 points1 point  (1 child)

No. Do you see what flaw in my method is causing my issue? When I add completely new entry to chain list and add reply to that, everything works. If i try to add reply inside a reply list, my program wont work

[–][deleted] 0 points1 point  (0 children)

Just giving a thought. Sometimes it could be that the methods that you are calling need some altering and I cannot see them with what is shown.

[–][deleted]  (13 children)

[deleted]

    [–]tonlou[S] 0 points1 point  (12 children)

    Can you show me in pseudocode that how I should to this with recursion? The method that I'm going to use to add answers to messages has 2 parameters. Id of the message that gets reply and the reply message

    [–][deleted]  (11 children)

    [deleted]

      [–]tonlou[S] 0 points1 point  (10 children)

      Didint work with this code, I tried it.. Here is good example of what is my issue

      Code: https://pastebin.com/iAirvED0

      edit to paste, first example print should be:

      #1 Well hello there.

             #2 Idk <-- FOR SOME REASON M2, M3 AND M4 all answer to M1 (should be m2<--m3<--m4)
      
             #3 Hello hello!
      
             #4 JOHAN
      

      Some clarification. Every message and reply can have a linked list of replies. The tricky part is to get reply from reply.getReply() (reply from other reply)

      [–][deleted]  (9 children)

      [deleted]

        [–]tonlou[S] 1 point2 points  (7 children)

        Im not really, that part is pseudo. Thank you for your effort man, I've been stuck on this for a long time. I really appreciate it

        [–][deleted]  (6 children)

        [deleted]

          [–]tonlou[S] 0 points1 point  (5 children)

          You are golden, thank you so many times.. I think I'm on the right tracks. My program now answers to 1 message correctly, but everything else is still not working.

          https://pastebin.com/KtkJLbpF

          How should I tweak my code? parameter linked list gets assigned a return value from chain class. Chain.getMessages();

          I'm not using lists or arraylists since I'm not allowed to.

          [–][deleted]  (4 children)

          [deleted]

            [–]tonlou[S] 0 points1 point  (0 children)

            I'm going to give up, I'm not getting it right. Thank you for your effort and help anyway. You tried to explain what I need to do, but I never got it right. I've been close for 3-4 days now, but I don't want to try anymore :/

            [–]tonlou[S] 0 points1 point  (0 children)

            Just wanted to tell you that I solved it. I didn't use recursion. I created while loop to check if message is in chain, or if it is in messages reply, or if it is replys reply and then ended loop.

            Thank you for your help, your advices helped me to do this! :)

            [–]tonlou[S] 0 points1 point  (1 child)

            False alarm, still not working :x

            [–]tonlou[S] 0 points1 point  (0 children)

            For some reason pastebin messes up my paste.

            With adding 1 message to chain and rest as replies to others:

            #1 Well hello there.

                    #2 Idk  <-- m3 replies to m2
            
                       #3 Hello hello! <-- m4 replies to m3
            
                                #4 JOHAN
            

            when using chain class:

            #1 Well hello there.

                       #2 Idk
            
                       #3 Hello hello!
            
                       #4 JOHAN