Results 1 to 10 of 10
  1. #1
    Jaymz is offline Member
    Join Date
    Oct 2008
    Posts
    5
    Rep Power
    0

    Default I need a back and forward code

    I have a functional TicTacToe 5x5 game with added back and forward buttons on the game board. I only need to implement the two functions for these two buttons, using Linked Lists, but I have no idea how to do it. How/what to store in Linked Lists, and then how to access the stored moves? Can anyone of you please share an idea (maybe a Java code snippet)?

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,518
    Rep Power
    25

    Default

    What do you mean by "back" and "forward"? What data would be needed to implement that? Can that data be put in a new class?
    Can you construct a board position from the data in the class?
    Then save an object of that class in a LinkedList.

    Start with a simple test program to exercise the LinkedList. When you see how to use its methods, then you can use that knowledge to write what you need in your progrm.

  3. #3
    Jaymz is offline Member
    Join Date
    Oct 2008
    Posts
    5
    Rep Power
    0

    Default

    Quote Originally Posted by Norm View Post
    What do you mean by "back" and "forward"? What data would be needed to implement that? Can that data be put in a new class?
    Can you construct a board position from the data in the class?
    Then save an object of that class in a LinkedList.

    Start with a simple test program to exercise the LinkedList. When you see how to use its methods, then you can use that knowledge to write what you need in your progrm.
    Norm, the two buttons should go back to a previous stored move, and respectively forward to a "future" move, in case I went back. I understand how to use linked lists because i studied it, but i have no idea what to store in the linked list's nodes.

    should it be (player, player's move, opponent's move) or what? and how to store that? how to call the previous move then? also after i went back a move or more moves, and if a click on the board for a new move, that should destroy all "future" moves and store new ones.

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,518
    Rep Power
    25

    Default

    what to store in the linked list's nodes
    What does it take to present any position in the game? All that must be saved. Design a class to hold that info. Then design a method to use an instance of that class to draw the board.

  5. #5
    Jaymz is offline Member
    Join Date
    Oct 2008
    Posts
    5
    Rep Power
    0

    Default

    this sounds like a general OOP advice. my problem is that i don't understand what exactly needs to be stored for a move. should be something like a node of (player, player's move, opponent's move)?

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,518
    Rep Power
    25

    Default

    I suggest that you store the board info after a move.
    What does it take to display the board? Store all that.
    Write a method that will take that info and display a position.

    If you only want to store moves, then what is a move in your game? The placing of a marker by one of the players. So a move would be the player and the postion he placed his marker.

  7. #7
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Please do not cross-post questions in multiple forums. This will frustrate anyone who tries to help you only to find out later that the same answer was given hours ago in a cross-posted thread.

    Sun Java Forum Thread

  8. #8
    Jaymz is offline Member
    Join Date
    Oct 2008
    Posts
    5
    Rep Power
    0

    Default

    i don't think so, but good for your observation point ;)
    by the way, is there a problem in cross posting back to your reply?
    Last edited by Jaymz; 10-12-2008 at 11:29 PM.

  9. #9
    javaSucks is offline Member
    Join Date
    Oct 2008
    Posts
    1
    Rep Power
    0

    Default

    hahahahaha are you serious?

    Jaymz see you in cs201 tmrw ;)

  10. #10
    Jaymz is offline Member
    Join Date
    Oct 2008
    Posts
    5
    Rep Power
    0

    Default

    javaSucks, what do you mean? i'm not a student if that number was a class number... since you seem to be somehow connected to this subject, can you please share your thoughts about it? unless Java really sux for you :D

Similar Threads

  1. Back button
    By Tokajac in forum Web Frameworks
    Replies: 1
    Last Post: 11-27-2008, 05:27 AM
  2. Back-Forward Simulation using stacks(java)
    By MarKus in forum New To Java
    Replies: 3
    Last Post: 09-10-2008, 01:47 PM
  3. Replies: 5
    Last Post: 07-29-2008, 02:13 PM
  4. Tim's back!
    By tim in forum Introductions
    Replies: 3
    Last Post: 06-29-2008, 05:50 AM
  5. jsp:forward action
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-24-2007, 10:04 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •