Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-12-2008, 10:25 PM
Member
 
Join Date: Oct 2008
Posts: 5
Jaymz is on a distinguished road
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
Sponsored Links
  #2 (permalink)  
Old 10-12-2008, 10:30 PM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Heredia, Costa Rica
Posts: 2,223
Norm is on a distinguished road
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, 11:37 PM
Member
 
Join Date: Oct 2008
Posts: 5
Jaymz is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 10-13-2008, 12:37 AM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Heredia, Costa Rica
Posts: 2,223
Norm is on a distinguished road
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-13-2008, 12:43 AM
Member
 
Join Date: Oct 2008
Posts: 5
Jaymz is on a distinguished road
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-13-2008, 12:51 AM
Norm's Avatar
Senior Member
 
Join Date: Jun 2008
Location: Heredia, Costa Rica
Posts: 2,223
Norm is on a distinguished road
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-13-2008, 01:10 AM
Fubarable's Avatar
Senior Member
 
Join Date: Jun 2008
Posts: 883
Fubarable is on a distinguished road
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-13-2008, 01:26 AM
Member
 
Join Date: Oct 2008
Posts: 5
Jaymz is on a distinguished road
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-13-2008 at 01:29 AM.
Bookmark Post in Technorati
Reply With Quote
  #9 (permalink)  
Old 10-13-2008, 01:47 AM
Member
 
Join Date: Oct 2008
Posts: 1
javaSucks is on a distinguished road
hahahahaha are you serious?

Jaymz see you in cs201 tmrw
Bookmark Post in Technorati
Reply With Quote
  #10 (permalink)  
Old 10-13-2008, 01:50 AM
Member
 
Join Date: Oct 2008
Posts: 5
Jaymz is on a distinguished road
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
Sponsored Links
Reply


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

vB 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 07:27 AM
Back-Forward Simulation using stacks(java) MarKus New To Java 3 09-10-2008 03:47 PM
<jsp:include> Vs <%@include> Vs <jsp:forward> Vs RequestDispatcher .forward/includeVs freddieMaize Java Servlet 5 07-29-2008 04:13 PM
Tim's back! tim Introductions 3 06-29-2008 07:50 AM
jsp:forward action Java Tip Java Tips 0 12-24-2007 12:04 PM


All times are GMT +3. The time now is 10:26 AM.


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