l***@gmail.com
2018-06-07 20:53:05 UTC
i'm new to visual basic and i want to make a 2 player game where player1 inputs a number and player2 has to guess it
i'm having trouble in finding ways to hide user inputs so that player2 has to actually guess the number
here's my code so far:
Module Module1
Sub Main()
Dim guess As Integer = 0
Dim N2guess As Integer = 0
Dim attempts As Integer = 0
Dim P1 As String = "P1"
Dim P2 As String = "P2"
Console.WriteLine("P1, please enter a number between 1-10 ")
N2guess = Console.ReadLine()
While N2guess < 1 Or N2guess > 10
Console.WriteLine("INVALID OPTION")
Console.WriteLine("please try again")
N2guess = Console.ReadLine()
End While
While guess <> N2guess And attempts < 5
Console.WriteLine("P2 have a guess")
guess = Console.ReadLine()
attempts = attempts + 1
End While
If guess = N2guess Then
Console.WriteLine("P2 WINS!")
Else
Console.WriteLine("P1 WINS!")
End If
Console.ReadLine()
End Sub
End Module
i'm having trouble in finding ways to hide user inputs so that player2 has to actually guess the number
here's my code so far:
Module Module1
Sub Main()
Dim guess As Integer = 0
Dim N2guess As Integer = 0
Dim attempts As Integer = 0
Dim P1 As String = "P1"
Dim P2 As String = "P2"
Console.WriteLine("P1, please enter a number between 1-10 ")
N2guess = Console.ReadLine()
While N2guess < 1 Or N2guess > 10
Console.WriteLine("INVALID OPTION")
Console.WriteLine("please try again")
N2guess = Console.ReadLine()
End While
While guess <> N2guess And attempts < 5
Console.WriteLine("P2 have a guess")
guess = Console.ReadLine()
attempts = attempts + 1
End While
If guess = N2guess Then
Console.WriteLine("P2 WINS!")
Else
Console.WriteLine("P1 WINS!")
End If
Console.ReadLine()
End Sub
End Module