【发布时间】:2020-02-03 21:00:48
【问题描述】:
所以我是编程新手,仍在学习我必须创建多项选择题,所以我制作了一个输出问题和答案的方法,但如果单击按钮检查,我不知道如何验证我的答案。将很高兴这里的一些专家能给我一个想法。
public partial class Form1: Form
{
public Form1()
{
InitializeComponent();
}
private void PresentQuestion()
{
radioButton1.Checked = false;
radioButton2.Checked = false;
radioButton3.Checked = false;
radioButton4.Checked = false;
Random rand = new Random();
int cycles = rand.Next(1, 4);
switch (cycles)
{
case 1:
textBox1.Text = "what is 15 - 8 ?";
radioButton1.Text = "A. 6";
radioButton2.Text = "B. 7";
radioButton3.Text = "C. 5";
radioButton4.Text = "D. 4";
break;
case 2:
textBox1.Text = "what is 5 x 5?";
radioButton1.Text = "A. 25";
radioButton2.Text = "B. 50";
radioButton3.Text = "C. 20";
radioButton4.Text = "D. 100";
break;
case 3:
textBox1.Text = "what is 4+4?";
radioButton1.Text = "A. 4";
radioButton2.Text = "B. 2";
radioButton3.Text = "C. 2";
radioButton4.Text = "D. 8";
break;
}
}
private void Form1_Load(object sender, EventArgs e)
{
PresentQuestion();
}
private void buttonCheck_Click(object sender, EventArgs e)
{
PresentQuestion();
}
}
}
【问题讨论】:
-
这看起来有点像作业。
标签: c# validation radio-button user-input