Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-12-2008, 08:25 PM
Member
 
Join Date: Oct 2008
Posts: 5
Rep Power: 0
Jaymz is on a distinguished road
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)?
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 10-12-2008, 08:30 PM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Heredia, Costa Rica
Posts: 2,225
Rep Power: 4
Norm is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 10-12-2008, 09:37 PM
Member
 
Join Date: Oct 2008
Posts: 5
Rep Power: 0
Jaymz is on a distinguished road
Default
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.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 10-12-2008, 10:37 PM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Heredia, Costa Rica
Posts: 2,225
Rep Power: 4
Norm is on a distinguished road
Default
Quote:
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.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 10-12-2008, 10:43 PM
Member
 
Join Date: Oct 2008
Posts: 5
Rep Power: 0
Jaymz is on a distinguished road
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)?
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 10-12-2008, 10:51 PM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Heredia, Costa Rica
Posts: 2,225
Rep Power: 4
Norm is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 10-12-2008, 11:10 PM
Fubarable's Avatar
Moderator
 
Join Date: Jun 2008
Posts: 3,189
Rep Power: 5
Fubarable is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
  #8 (permalink)  
Old 10-12-2008, 11:26 PM
Member
 
Join Date: Oct 2008
Posts: 5
Rep Power: 0
Jaymz is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
  #9 (permalink)  
Old 10-12-2008, 11:47 PM
Member
 
Join Date: Oct 2008
Posts: 1
Rep Power: 0
javaSucks is on a distinguished road
Default
hahahahaha are you serious?

Jaymz see you in cs201 tmrw
Bookmark Post in Technorati
Reply With Quote
  #10 (permalink)  
Old 10-12-2008, 11:50 PM
Member
 
Join Date: Oct 2008
Posts: 5
Rep Power: 0
Jaymz is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Back button Tokajac Web Frameworks 1 11-27-2008 05:27 AM
Back-Forward Simulation using stacks(java) MarKus New To Java 3 09-10-2008 01:47 PM
<jsp:include> Vs <%@include> Vs <jsp:forward> Vs RequestDispatcher .forward/includeVs freddieMaize Java Servlet 5 07-29-2008 02:13 PM
Tim's back! tim Introductions 3 06-29-2008 05:50 AM
jsp:forward action Java Tip Java Tips 0 12-24-2007 10:04 AM


All times are GMT +2. The time now is 06:32 AM.



VBulletin, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org