RSS Forums RSS

Knight's Tour Using a Stack

Please support our Java advertiser: Programming Forums
Reply
Posts: 31
Reputation: scream2ice is an unknown quantity at this point 
Solved Threads: 0
scream2ice scream2ice is offline Offline
Light Poster

Knight's Tour Using a Stack

  #1  
Oct 12th, 2008
I'm trying to write a program in java...it's actually the famous game of "Knight's Tour" - I guess you're all familiar with it- just for a brief explanation
what I have to do is to get from the user the row and the coloumn of the square on the board where the knight wants to start moving, and from that position USING A STACK to store the square details, move around the board until the knight goes through ALL the squares of the board only once. When the knight moves into one square it cannot go to that square again, so using a stack the knight comes across a time when it reaches a dead end and that's when it comes back to the previous house

I really need some help on how to begin with this!
The whole 'stack' thing really bugs me now......i'm confused
AddThis Social Bookmark Button
Reply With Quote  
Posts: 663
Reputation: darkagn has a spectacular aura about darkagn has a spectacular aura about 
Solved Threads: 88
darkagn's Avatar
darkagn darkagn is offline Offline
Practically a Master Poster

Re: Knight's Tour Using a Stack

  #2  
Oct 12th, 2008
So a Stack is just a data structure that follows the Last In First Out rule (LIFO). This means that the last item placed on the stack (with an add or push method of some description) will be the next to be removed (by a call to a remove or pop method).

The Java API provides a basic Stack class that you can use (in the java.util package).
There are no stupid questions, only those too stupid to ask for help.
Reply With Quote  
Posts: 1,158
Reputation: javaAddict is just really nice javaAddict is just really nice javaAddict is just really nice javaAddict is just really nice 
Solved Threads: 163
javaAddict's Avatar
javaAddict javaAddict is offline Offline
Veteran Poster

Re: Knight's Tour Using a Stack

  #3  
Oct 13th, 2008
Also if you had searched the forum, you would have come up with this post about Stack. Others had the same question as you, so you could have searched to see your question answered

http://www.daniweb.com/forums/thread146631.html
There are 3 ways to do things:
The right way, the wrong way,
And The Object Oriented Way.

When you do things your way, make sure you don't forget the Object Oriented Way
Reply With Quote  
Posts: 31
Reputation: scream2ice is an unknown quantity at this point 
Solved Threads: 0
scream2ice scream2ice is offline Offline
Light Poster

Re: Knight's Tour Using a Stack

  #4  
Oct 13th, 2008
thanks alot
i'm coming up with some ideas
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.



Similar Threads
Other Threads in the Java Forum
Views: 1216 | Replies: 3 | Currently Viewing: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 10:56 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC