I'm needing to make scissors win over paper, and rock win over scissors, and etc. I currently have the statement userChoice != computerChoice but this would not work as rock would win over paper. I don't know how to make this work, I've tried thinking and can't think of anything currently, I'm only a beginning programmer.
const int ROCK = 1;
const int PAPER = 2;
const int SCISSORS = 3;
private void rockButton_Click(object sender, EventArgs e)
{
int userChoice = ROCK;
userPictureBox.Image = Properties.Resources.Rock;
Random randomNumberGenerator = new Random();
int computerChoice = randomNumberGenerator.Next(1, 4);
switch (computerChoice)
{
case ROCK:
computerPictureBox.Image = Properties.Resources.Rock;
break;
case PAPER:
computerPictureBox.Image = Properties.Resources.Paper;
break;
case SCISSORS:
computerPictureBox.Image = Properties.Resources.Scissors;
break;
}
if (userChoice == computerChoice)
MessageBox.Show("It's a tie.");
else if (userChoice != computerChoice)
{
MessageBox.Show("You win!");
}
}
private void paperButton_Click(object sender, EventArgs e)
{
int userChoice = PAPER;
userPictureBox.Image = Properties.Resources.Paper;
Random randomNumberGenerator = new Random();
int computerChoice = randomNumberGenerator.Next(1, 4);
switch (computerChoice)
{
case ROCK:
computerPictureBox.Image = Properties.Resources.Rock;
break;
case PAPER:
computerPictureBox.Image = Properties.Resources.Paper;
break;
case SCISSORS:
computerPictureBox.Image = Properties.Resources.Scissors;
break;
}
if (userChoice == computerChoice)
MessageBox.Show("It's a tie.");
else if (userChoice != computerChoice)
{
MessageBox.Show("You win!");
}
}
private void scissorsButton_Click(object sender, EventArgs e)
{
int userChoice = SCISSORS;
userPictureBox.Image = Properties.Resources.Scissors;
Random randomNumberGenerator = new Random();
int computerChoice = randomNumberGenerator.Next(1, 4);
switch (computerChoice)
{
case ROCK:
computerPictureBox.Image = Properties.Resources.Rock;
break;
case PAPER:
computerPictureBox.Image = Properties.Resources.Paper;
break;
case SCISSORS:
computerPictureBox.Image = Properties.Resources.Scissors;
break;
}
if (userChoice == computerChoice)
MessageBox.Show("It's a tie.");
else if (userChoice != computerChoice)
{
MessageBox.Show("You win!");