dimanche 11 novembre 2018

Random numbers and image display based with radio button

I'm having trouble with my code. I'm trying to display two random numbers and with using the radio buttons to display in two boxes (one left and right) and also trying to display an image in the middle box.

Here's a picture of the design:

private void GenerateDisplayProblem(); {

    Random rand = new Random();
    int num = rand.Next(1, 30);


    if (radLevel1.Checked)
    {
        num = rand.Next(1, 10);
    }
    if (radLevel2.Checked)
    {
        num = rand.Next(1, 20);
    }
    if (radLevel3.Checked)
    {
        num = rand.Next(1, 30);
    }


    lblNumber1.Text = num.ToString();
    lblNumber2.Text = num.ToString();


    //Operator image
if (radAdd.Checked)
    {
        picOperator.Image = Image.FromFile("Plus.jpg");
    }
    if (radSubtraction.Checked)
    {
        picOperator.Image = Image.FromFile("Minus.jpg");
    }

    if (radMultiply.Checked)
    {
        picOperator.Image = Image.FromFile("Multiply.jpg")
    }


    private void btnCheckAnswer_Click(object sender, EventArgs e)
    {
        radLevel1.Enabled = false;
        radLevel2.Enabled = false;
        radLevel3.Enabled = false;

        radAdd.Enabled = false;
        radSubtraction.Enabled = false;
        radMultiply.Enabled = false;




Aucun commentaire:

Enregistrer un commentaire