Welcome to Dream.In.Code
Become a VB Expert!

Join 137,233 VB Programmers for FREE! Get instant access to thousands of VB experts, tutorials, code snippets, and more! There are 1,799 people online right now. Registration is fast and FREE... Join Now!




Help with Hangman Game Assignment

 
Reply to this topicStart new topic

Help with Hangman Game Assignment

shackman
21 Feb, 2007 - 07:52 AM
Post #1

New D.I.C Head
*

Joined: 21 Feb, 2007
Posts: 5


My Contributions
Greetings to all ...

I am a novice programmer at best, and I am currently enrolled in a VB .net college course.

Our final project is to assemble a simple Hangman program, which randomnly selects a word each time from a seperate text file.

Me being the novice that I am, would appreciate any assistance anyone would be able to provide regarding how to structure such a program as well as where to begin on such an extensive program.

Thank-you all in advance ... smile.gif
User is offlineProfile CardPM
+Quote Post

skyhawk133
RE: Help With Hangman Game Assignment
21 Feb, 2007 - 08:06 AM
Post #2

Head DIC Head
Group Icon

Joined: 17 Mar, 2001
Posts: 14,970



Thanked: 48 times
Dream Kudos: 1650
Expert In: Web Development

My Contributions
If I were doing this in any language, I would create the functions for each step of the program. This would include functions like drawHangman, guess, loadWord.

I assume since this is a final exam you've got at least some knowledge in VB .NET. Are there any areas you feel you need specific help with.

Also, once you get started, if you post your code we can help you fill in the gaps and make sure you understand what you're doing.

Best of luck!
User is online!Profile CardPM
+Quote Post

shackman
RE: Help With Hangman Game Assignment
21 Feb, 2007 - 08:13 AM
Post #3

New D.I.C Head
*

Joined: 21 Feb, 2007
Posts: 5


My Contributions
Actually, this is our final program to turn in (not our final exam).

Unfortunately, this is unlike any other program we have had to turn in so far. This is a beginner's class and to be honest, I don't feel that this is a begineer's homework assignment.

I am basically looking for some general direction in order to get started on this project.

Once I have started, I will be more than glad to post my code in order to receive some additional assistance with the project.

Thanks...

User is offlineProfile CardPM
+Quote Post

m2s87
RE: Help With Hangman Game Assignment
21 Feb, 2007 - 08:23 AM
Post #4

D.I.C Regular
Group Icon

Joined: 28 Nov, 2006
Posts: 390



Thanked: 1 times
Dream Kudos: 1225
My Contributions
Probably you have solved your problem for now, so it would not hurt to show, that actually there is a snippet in VB, that does just that.

http://www.dreamincode.net/code/snippet848.htm
User is offlineProfile CardPM
+Quote Post

shackman
RE: Help With Hangman Game Assignment
21 Feb, 2007 - 08:30 AM
Post #5

New D.I.C Head
*

Joined: 21 Feb, 2007
Posts: 5


My Contributions
Actually ... my problem is not yet solved. In fact, I am just now getting started.

I appreciate the link, unfortunately, that program was written in VB5, and I am looking for some assistance in VB .net.

So again, if anyone can give me some general direction to take in assembly a basic hangman program in VB .net, I would greatly appreciate it.

Thanks...
User is offlineProfile CardPM
+Quote Post

skyhawk133
RE: Help With Hangman Game Assignment
21 Feb, 2007 - 08:40 AM
Post #6

Head DIC Head
Group Icon

Joined: 17 Mar, 2001
Posts: 14,970



Thanked: 48 times
Dream Kudos: 1650
Expert In: Web Development

My Contributions
Do you know how to read from a file?

Do you know how to create an array?

Do you know how to accept user input?

Do you know how to create a function?

Do you know how to return an image or set of characters to the screen?

Do you know how to create a random number?

These are the concepts you'll need to complete a h1angman program. We can't help you until we know what to help you with.
User is online!Profile CardPM
+Quote Post

m2s87
RE: Help With Hangman Game Assignment
21 Feb, 2007 - 08:52 AM
Post #7

D.I.C Regular
Group Icon

Joined: 28 Nov, 2006
Posts: 390



Thanked: 1 times
Dream Kudos: 1225
My Contributions
Make an event New game
1. visualize what can be picked(maybe add buttons to choose from)
2. set the guessing count to 0
3. generate a word to guess (from database, enumeration or prefilled array)
4. show some stats

Make an event guess
1. Disable picking it again
2. hit?
y) win? add new stats
n) draw/show graphics; loose? add new stats
3. quit?

Make an event Reset
1. reset hanging grapics
2. enable all letters to pick from

And it's is.
User is offlineProfile CardPM
+Quote Post

shackman
RE: Help With Hangman Game Assignment
21 Feb, 2007 - 11:16 AM
Post #8

New D.I.C Head
*

Joined: 21 Feb, 2007
Posts: 5


My Contributions
To: skyhawk133 - yes I know how to do all of these things on a very basic level. I just don't know what steps to put them in or how to structure the program in order to achieve constructing such a program.

I was looking for something along the lines of what m2s87 provided - thankyou m2s87.

I will provide the code for any additional questions I have with this project.

Thanks again for the assistance...
User is offlineProfile CardPM
+Quote Post

shackman
RE: Help With Hangman Game Assignment
22 Feb, 2007 - 08:37 AM
Post #9

New D.I.C Head
*

Joined: 21 Feb, 2007
Posts: 5


My Contributions
Okay ... I am currently having a problem selecting a random word from a text file.

The line that assigns SelectedWord to equal CStr(words(iLine)) is where I am getting the following error ...

Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index


Any assistance would be greatly appreciated.

Thanks...

CODE
Function GetRandomWord(ByVal filename As String) As String

      'Open the file
      Try
         filename = "wordlist.txt"
        
         stream = New StreamReader(filename)

         'Checks to see if the file exists and then loads the file
         If File.Exists(filename) Then

            Do While stream.Peek <> -1
               strText = stream.ReadLine()

            Loop


         End If

         'Populates system error message if file doesn't exist
      Catch ex As System.IO.IOException
         MessageBox.Show(ex.Message)


      End Try


      'Read in all the lines into an ArrayList
      Dim words As ArrayList = New ArrayList()
      Dim word As String = Stream.ReadLine()
      While Not word Is Nothing
         words.Add(word)
         word = Stream.ReadLine()
      End While

      'Close the Text file
      stream.Close()

      'Now, randomly choose a word from the word ArrayList
      Dim rndNum As Random = New Random()
      Dim iLine As Integer = rndNum.Next(words.Count)
      Dim selectedWord As String = CStr(words(iLine))
      Return selectedWord

User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/4/08 03:35PM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month