我有这个子手的代码,但没有给我每个玩家的分数 [英] i have this code for hangman but it doesnt give me the points of each player
本文介绍了我有这个子手的代码,但没有给我每个玩家的分数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
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
推荐答案
这是一个人的子手,我需要你让2个玩家使用它
要点会像这样:
找一个字母= 10
找到单词= 50
程序每次询问谁将参加比赛,最后询问是否要进行另一场比赛?".而当答案为否时,它将停止并给出所有匹配项的结果."
我们不做您的作业:这是有原因的.在这里,您可以考虑自己被告知的内容,并尝试理解它.也可以在那里帮助您的导师识别您的弱点,并将更多的注意力放在补救措施上.
自己尝试,或学习魔语:您要用它炸薯条吗?"
"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?"
转到此处 [ ^ ]
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
这篇关于我有这个子手的代码,但没有给我每个玩家的分数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文