Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 I need some help with functions.
Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Silent Avenger




PostPosted: Sun Nov 26, 2006 10:21 pm   Post subject: I need some help with functions.

Okay I'm making a program that will solve the tower of hanoi game. I think I've got the proper function to solve it but I'm not quite sure how to output information on how to solve the game eg. move disk 1 to peg 2, move disk 2 to peg 3, move disk 1 to peg 3, etc.

if no one knows what I'm talking about here's a website with the game: http://www.cut-the-knot.org/recurrence/hanoi.shtml

Help with this would be greatly appreciated.
Sponsor
Sponsor
Sponsor
sponsor
wtd




PostPosted: Sun Nov 26, 2006 11:55 pm   Post subject: (No subject)

Care to show us the code you have, thus far?
Silent Avenger




PostPosted: Mon Nov 27, 2006 8:08 am   Post subject: (No subject)

Oh right, sorry I forgot to post it. Okay here's the code I have so far:
code:
Private Function MoveTower(Disk As Integer, Source As Integer, Dest As Integer, Spare As Integer)
    If Disk = 0 Then
      MoveDisks Disk, Source, Dest
    Else
      MoveTower Disk - 1, Source, Spare, Dest
      MoveDisks Disk, Source, Dest
      MoveTower Disk - 1, Spare, Dest, Source
    End If
End Function

Private Sub Command1_Click()
MoveTower text1.Text
End Sub
wtd




PostPosted: Mon Nov 27, 2006 8:35 am   Post subject: (No subject)

Cannot MoveDisks and/or MoveTower affect the value of some text field?
Silent Avenger




PostPosted: Tue Nov 28, 2006 5:36 pm   Post subject: (No subject)

The value of the text field should not be affected though because it's the number of disks in the game.
cool dude




PostPosted: Sun Dec 03, 2006 4:45 pm   Post subject: (No subject)

umm, i'm not to sure on what you were asking for help with. but i think this might help you quite a bit. (Scroll to the very bottom) http://www.ecoo.org/jketelaars/java2/java1.html
Silent Avenger




PostPosted: Sun Dec 03, 2006 10:36 pm   Post subject: (No subject)

Okay thanks cool dude.
cool dude




PostPosted: Sun Dec 03, 2006 11:09 pm   Post subject: (No subject)

Silent Avenger wrote:
Okay thanks cool dude.


haha i've been doing java all day and got mixed up with forums. sorry i gave you a link to your solution in java code. If you need any help translating the code just ask.

P.S. i had to write the pseudo code for Hanoi for one of my assignments just recently.
Sponsor
Sponsor
Sponsor
sponsor
Silent Avenger




PostPosted: Mon Dec 04, 2006 6:45 pm   Post subject: (No subject)

It's okay cool dude, I managed to figure it out with the help of the website.
Display posts from previous:   
   Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 9 Posts ]
Jump to:   


Style:  
Search: