Click here to Skip to main content
15,881,898 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
VB
Module Module1
    'This program displays the word Computer as C ------ r and asks the user
    'To guess letters. Each time you correctly guess the letter appears in the corresponding position
    'Every time you make a mistake loses an opportunity-life.
    'The game ends when either guess all the letters or zero opportunities-lives of the user
    Public zoes As Byte 'The variable opportunities, lives the player has
    Public ans As String
    Public ans2 As String
    Public pointspl1 As Integer
    Public pointspl2 As Integer
    Public complete As Integer
    Public turn As String
    Public t As String

    Sub Main ()
        Do
            Console.writeline ("---------- HAngMAn ---------- ")
           
            Dim Pl1 As String
            Dim Pl2 As String
            Dim word As String 'Initialize the secret word Computer
            Dim display As String 'Create the word that appears in the user
            Dim letter As String

            console.writeline ("")
            console.writeline ("Give me the name of the first player:")
            Pl1 = console.readline ()
            console.writeline ("")
            console.writeline ("Give me the name of the second player:")
            Pl2 = console.readline ()
            Do
                console.writeline ("")
                console.writeline ("Who will give the word? (1 for player1 and 2 for player2)")
                Do
                    t = console.readline
                Loop Until t = 1 Or t = 2
                If t = 1 Then
                    turn = Pl1
                ElseIf t = 2 Then
                    turn = Pl2
                End If
                Do
                    console.writeline ("")
                    Console.WriteLine ("it's your turn player:" & turn)
                    If word <> "end" Or word <> "End" Then
                        console.writeline ("")
                        Console.Writeline ("Please enter keyword")
                        word = Console.ReadLine ()
                        display = MakeDisplay (word)
                    End If
                    zoes = Len (word) - 2 'Specify number of attempts, many lives are hidden words
                    complete = Len (word) - 2
                    Do
                        console.writeline ("")
                        Console.WriteLine ("Give a timetable for the word" & display)
                        letter = Console.ReadLine
                        Call FindLetters (word, letter, display, pointspl1, pointspl2)
                    Loop Until (word = display) Or zoes = 0 'This will be repeated until the word word be the same
                    'With the word display, ie the player to guess completely unknown word or to
                    'Life-chances are the player to run out
                Loop Until (word = display) Or zoes = 0
                console.writeline ("")
                console.writeline ("Want another match?:")
                ans = Console.ReadLine ()
            Loop Until ans = "No"
            console.writeline ("End")
            console.writeline ("points" & Pl1 & ":" & pointspl1)
            console.writeline ("points" & Pl1 & ":" & pointspl2)
            If pointspl1> pointspl2 Then
                Console.writeline ("The Winner is:" & Pl1)
            Else
                console.writeline ("The Winner is:" & Pl2)
            End If
            console.writeline ("")
            console.writeline ("Want another Game?:")
            ans2 = Console.ReadLine ()
        Loop Until ans2 = "No"
    End Sub

    Public Function MakeDisplay (ByVal w As String) As String 'He makes the word of the gallows with the intermediate paflitses
        Dim display As String, c As Byte
        display = Left (w, 1)
        For c = 2 To Len (w) - 1
            display = display & "-"
        Next
        display = display & Right (w, 1)
        Return display
    End Function

    Public Sub FindLetters (ByVal w As String, ByVal letter As String, ByRef display As String, ByVal pointspl1 As Integer, ByVal pointspl2 As Integer)
        'Looking to find the letter in the word w and sets the current display, depending
        'Also, if you do not find the character letter in the word w then reduces the lives of the player by 1
        Dim c As Byte, found As Boolean
        found = False 'flag is true when the letter letter found in the word w
        For c = 2 To Len (w) - 1
            If Mid (w, c, 1) = letter Then
                display = Left (display, c - 1) & letter & Right (display, Len (display) - c)
                'The new display is made by joining pieces: left (to position the letter letter)
                'The letter letter found and
                'The right (taking characters from the end of the word display letter by letter
                found = True
                complete = complete - 1
                If t = 1 Then
                    pointspl2 = pointspl2 + 10
                ElseIf t = 2 Then
                    pointspl1 = pointspl1 + 10
                End If
            End If
        Next
        If Not found Then
            Console.WriteLine ("")
            Console.WriteLine ("There is the letter" & letter)
            zoes -= 1
        Else
            Console.WriteLine ("")
            Console.WriteLine ("Good Guessing the letter" & letter)
        End If
        Console.WriteLine ("")
        Console.WriteLine ("Do you still" & zoes & "lives!")
        If zoes = 0 Then
            Console.WriteLine ("")
            Console.WriteLine ("Sorry you lost!")
        End If
        If complete = 0 Then
            Console.WriteLine ("")
            Console.WriteLine ("you have found the word!!")
            If t = 1 Then
                pointspl2 = pointspl2 + 50
            ElseIf t = 2 Then
                pointspl1 = pointspl1 + 50
            End If
        End If

    End Sub
End Module
Posted
Updated 29-Nov-11 12:57pm
v8
Comments
Sergey Alexandrovich Kryukov 28-Nov-11 19:22pm    
This is a code dump, not a question. What's the problem? And who will translate it all into English? Someone who is less lazy? (Please pay attention: this is English-speaking forum.) Now, I wonder who needs help...
--SA
AngeLsEyes 29-Nov-11 5:35am    
can u help me?i fix it
OriginalGriff 29-Nov-11 5:57am    
Better - but what is the problem? You don't tell us what needs fixing - and I am not going to play hangman all day trying to work out which bug you mean! :laugh:
AngeLsEyes 29-Nov-11 18:59pm    
now can u fix it?
LanFanNinja 29-Nov-11 20:48pm    
Ok so I played it! ;) And there is a few problems for sure. I truly suggest that you rewrite the whole thing and if it doesn't work then ... write it some more times until it does work! I am not saying this to be mean when I started programming that is exactly what I did. I wrote the same programs over and over until I was happy with the way they turned out. Good Luck. :)

"this is hangman for one person and i need u to make it for 2 players
the points will go like this :
find a letter= 10
find the word= 50
every time the program asks who will play and at the end asks "want another match?" and when the answer is no then it stops and gives the result of all the matches.."


We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, or learn the Magic Words: "Do you want fries with that?"
 
Share this answer
 
Comments
AngeLsEyes 29-Nov-11 8:47am    
ty for opening my eyes ^^ i will never do that again. i will try it but can i send u the code after i finish with this and tell if it's good? (plz)
AngeLsEyes 29-Nov-11 11:53am    
i want to ask u a Question do u have skype or fb or somethink that i can communicate with u? even email...
Smithers-Jones 1-Dec-11 4:48am    
We have Codeproject for communication. What's wrong with talking about it here? Either discuss your problem here or forget it. Probably nobody here's gonna give you their email-adress or other contact information.
AngeLsEyes 1-Dec-11 11:46am    
ok sry didnt knew,.. i wanted more fast communication like live chat but ok sry again
 
Share this answer
 
Comments
Maciej Los 29-Nov-11 13:00pm    
It's not a solution, but it's a really good warning. ;)
Module Module1
    'This program displays the word Computer as C ------ r and asks the user
    'To guess letters. Each time you correctly guess the letter appears in the corresponding position
    'Every time you make a mistake loses an opportunity-life.
    'The game ends when either guess all the letters or zero opportunities-lives of the user
    Public zoes As Byte 'The variable opportunities, lives the player has
    Public ans As String
    Public ans2 As String
    Public pointspl1 As Integer
    Public pointspl2 As Integer
    Public complete As Integer
    Public turn As String
    Public t As String

    Sub Main ()
        Do
            Console.writeline ("---------- HAngMAn ---------- ")
           
            Dim Pl1 As String
            Dim Pl2 As String
            Dim word As String 'Initialize the secret word Computer
            Dim display As String 'Create the word that appears in the user
            Dim letter As String

            console.writeline ("")
            console.writeline ("Give me the name of the first player:")
            Pl1 = console.readline ()
            console.writeline ("")
            console.writeline ("Give me the name of the second player:")
            Pl2 = console.readline ()
            Do
                console.writeline ("")
                console.writeline ("Who will give the word? (1 for player1 and 2 for player2)")
                Do
                    t = console.readline
                Loop Until t = 1 Or t = 2
                If t = 1 Then
                    turn = Pl1
                ElseIf t = 2 Then
                    turn = Pl2
                End If
                Do
                    console.writeline ("")
                    Console.WriteLine ("it's your turn player:" & turn)
                    If word <> "end" Or word <> "End" Then
                        console.writeline ("")
                        Console.Writeline ("Please enter keyword")
                        word = Console.ReadLine ()
                        display = MakeDisplay (word)
                    End If
                    zoes = Len (word) - 2 'Specify number of attempts, many lives are hidden words
                    complete = Len (word) - 2
                    Do
                        console.writeline ("")
                        Console.WriteLine ("Give a timetable for the word" & display)
                        letter = Console.ReadLine
                        Call FindLetters (word, letter, display, pointspl1, pointspl2)
                    Loop Until (word = display) Or zoes = 0 'This will be repeated until the word word be the same
                    'With the word display, ie the player to guess completely unknown word or to
                    'Life-chances are the player to run out
                Loop Until (word = display) Or zoes = 0
                console.writeline ("")
                console.writeline ("Want another match?:")
                ans = Console.ReadLine ()
            Loop Until ans = "No"
            console.writeline ("End")
            console.writeline ("points" & Pl1 & ":" & pointspl1)
            console.writeline ("points" & Pl1 & ":" & pointspl2)
            If pointspl1> pointspl2 Then
                Console.writeline ("The Winner is:" & Pl1)
            Else
                console.writeline ("The Winner is:" & Pl2)
            End If
            console.writeline ("")
            console.writeline ("Want another Game?:")
            ans2 = Console.ReadLine ()
        Loop Until ans2 = "No"
    End Sub

    Public Function MakeDisplay (ByVal w As String) As String 'He makes the word of the gallows with the intermediate paflitses
        Dim display As String, c As Byte
        display = Left (w, 1)
        For c = 2 To Len (w) - 1
            display = display & "-"
        Next
        display = display & Right (w, 1)
        Return display
    End Function

    Public Sub FindLetters (ByVal w As String, ByVal letter As String, ByRef display As String, ByVal pointspl1 As Integer, ByVal pointspl2 As Integer)
        'Looking to find the letter in the word w and sets the current display, depending
        'Also, if you do not find the character letter in the word w then reduces the lives of the player by 1
        Dim c As Byte, found As Boolean
        found = False 'flag is true when the letter letter found in the word w
        For c = 2 To Len (w) - 1
            If Mid (w, c, 1) = letter Then
                display = Left (display, c - 1) & letter & Right (display, Len (display) - c)
                'The new display is made by joining pieces: left (to position the letter letter)
                'The letter letter found and
                'The right (taking characters from the end of the word display letter by letter
                found = True
                complete = complete - 1
                If t = 1 Then
                    pointspl2 = pointspl2 + 10
                ElseIf t = 2 Then
                    pointspl1 = pointspl1 + 10
                End If
            End If
        Next
        If Not found Then
            Console.WriteLine ("")
            Console.WriteLine ("There is the letter" & letter)
            zoes -= 1
        Else
            Console.WriteLine ("")
            Console.WriteLine ("Good Guessing the letter" & letter)
        End If
        Console.WriteLine ("")
        Console.WriteLine ("Do you still" & zoes & "lives!")
        If zoes = 0 Then
            Console.WriteLine ("")
            Console.WriteLine ("Sorry you lost!")
        End If
        If complete = 0 Then
            Console.WriteLine ("")
            Console.WriteLine ("you have found the word!!")
            If t = 1 Then
                pointspl2 = pointspl2 + 50
            ElseIf t = 2 Then
                pointspl1 = pointspl1 + 50
            End If
        End If

    End Sub
End Module
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900