Hi there, I'm a beginner c# programmer, for practice I did the following code for a rock scissor paper game, the computer picks out it's choice randomly and compares with the player's choice. This code seem not to work properly, please help :?:
<%@ Page Language="c#" %>
<script runat="server">
void Page_Load()
{
if (Page.IsPostBack)
{
public String toSring()
{
int intcomputerChoice=1;
if(computerChoice==1)
{
return(Rock);
}
if(computerChoice==2)
{
return(Paper);
}
if(computerChoice==3)
{
return(Scissors);
}
}
if (Page.IsPostBack)
{
int intvalue;
Random rand = new Random(3);
value = Convert.ToInt32(rand.Next(3)) + 1;
if (Page.IsPostBack)
{
int intOption;
intOption =
Convert.ToInt32(Option.SelectedItem.Value);
if (intOption == 1 && value == 2)
{
message.Text =
computerChoice.ToString() + "You Lose!";
}
else if (intOption == 1 && value == 3)
{
message.Text =
"ROCK beats scissor! You win!";
}
else if (intOption == 2 && value == 1)
{
message.Text =
"PAPER beats rock! You win!";
}
else if (intOption == 2 && value == 3)
{
message.Text =
"SCISSOR beats paper! You lose!";
}
else if (intOption == 3 && value == 1)
{
message.Text =
"ROCK beats scissors! You lose!";
}
else if (intOption == 3 && value == 2)
{
message.Text =
"SCISSORS beats paper! You win!";
}
}
}
}
</script>
<html>
<head><title></title></head>
<body>
<form id="Form1" runat="server">
Welcome to Rock,Paper,Scissors Game
<br /><br />
Choose: Rock, Paper or Scissors?
<asp:dropdownlist id="Option" runat="server">
<asp:listitem Value="1">Rock</asp:listitem>
<asp:listitem Value= "2">Paper</asp:listitem>
<asp:listitem Value= "3">Scissors</asp:listitem>
</asp:dropdownlist>
<br />
<br />
<input type="submit" value="Challenge Computer" />
<asp:label id="message" runat="server"/>
</body>
</html>