I am working on a random number guessing game for my class and so far I have not really been able to figure out where I am going wrong. As far as I can tell my syntax is correct, I think that maybe I am just missing something. Any help would be greatly appreciated.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace GuessANumber
{
public partial class GuessANumber : Form
{
int correctAnswer;
int randomNumB;
public GuessANumber()
{
InitializeComponent();
Random RandomNumGernerator = new Random();
correctAnswer = RandomNumGernerator.Next(1,6);
Random RandomNum = new Random();
randomNumB = RandomNum.Next(1, 5);
while (randomNumB == correctAnswer)
randomNumB = RandomNum.Next(1, 6);
}
private void exitToolStripMenuItem_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void numGuess1_CheckedChanged(object sender, EventArgs e)
{
if (Convert.ToInt16(numGuess1.Text) == correctAnswer)
this.lblOutput.Text = "correct answer";
else
this.lblOutput.Text = "incorrect answer";
}
private void numGuess2_CheckedChanged(object sender, EventArgs e)
{
if (Convert.ToInt16(numGuess2.Text) == correctAnswer)
this.lblOutput.Text = "correct answer";
else
this.lblOutput.Text = "incorrect answer";
}
private void numGuess3_CheckedChanged(object sender, EventArgs e)
{
if (Convert.ToInt16(numGuess3.Text) == correctAnswer)
this.lblOutput.Text = "correct answer";
else
this.lblOutput.Text = "incorrect answer";
}
private void numGuess4_CheckedChanged(object sender, EventArgs e)
{
if (Convert.ToInt16(numGuess4.Text) == correctAnswer)
this.lblOutput.Text = "correct answer";
else
this.lblOutput.Text = "incorrect answer";
}
private void numGuess5_CheckedChanged(object sender, EventArgs e)
{
if (Convert.ToInt16(numGuess5.Text) == correctAnswer)
this.lblOutput.Text = "correct answer";
else
this.lblOutput.Text = "incorrect answer";
}
private void lblOutput_MouseHover(object sender, EventArgs e)
{
lblOutput.Text = "The correct button is not #" + randomNumB.ToString();
}
}
}