Learn More →
public partial class Form1 : Form
{
int success = 0;
int error = 0;
public Form1()
{
InitializeComponent();
label8.Text = "5";
label9.Text = "0";
label10.Text = "0";
//按鈕關閉
button1.Enabled = false;
button2.Enabled = false;
button4.Enabled = false;
}
private void button1_Click(object sender, EventArgs e)
{
int[] randomArray = new int[5];
int aws;
Random rnd = new Random();
for (int i = 0; i < 5; i++)
{
randomArray[i] = rnd.Next(1, 10);
for (int j = 0; j < i; j++)
{
while (randomArray[j] == randomArray[i])
{
j = 0;
randomArray[i] = rnd.Next(1, 10);
}
}
}
label8.Text = (Convert.ToInt32(label8.Text) - 1).ToString();
label6.Text = randomArray[0].ToString();
label7.Text = randomArray[1].ToString();
aws = randomArray[0] + randomArray[1];
if (aws % 2 == 0)
{
MessageBox.Show("恭喜你!!!猜中了", "", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
success += 1;
label9.Text = success.ToString();
}
else
{
MessageBox.Show("ㄛ喔!!!猜錯了", "", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
error += 1;
label10.Text = error.ToString();
}
if (Convert.ToInt32(label8.Text) == 0)
{
MessageBox.Show("遊戲結束 ,按重設以開始遊戲");
button1.Enabled = false;
button2.Enabled = false;
button3.Enabled = false;
button4.Enabled = true;
}
}
private void button2_Click(object sender, EventArgs e)
{
int[] randomArray = new int[5];
int aws;
Random rnd = new Random();
for (int i = 0; i < 5; i++)
{
randomArray[i] = rnd.Next(1, 10);
for (int j = 0; j < i; j++)
{
while (randomArray[j] == randomArray[i])
{
j = 0;
randomArray[i] = rnd.Next(1, 10);
}
}
}
label8.Text = (Convert.ToInt32(label8.Text) - 1).ToString();
label6.Text = randomArray[0].ToString();
label7.Text = randomArray[1].ToString();
aws = randomArray[0] + randomArray[1];
if (aws % 2 == 0)
{
MessageBox.Show("ㄛ喔!!!猜錯了", "", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
error += 1;
label10.Text = error.ToString();
}
else
{
MessageBox.Show("恭喜你!!!猜中了", "", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
success += 1;
label9.Text = success.ToString();
}
if (Convert.ToInt32(label8.Text) == 0)
{
MessageBox.Show("遊戲結束 ,按重設以開始遊戲");
button1.Enabled = false;
button2.Enabled = false;
button3.Enabled = false;
button4.Enabled = true;
}
}
private void button4_Click(object sender, EventArgs e)
{
success = 0;
error = 0;
label6.Text = "";
label7.Text = "";
label8.Text = "5";
label9.Text = "0";
label10.Text = "0";
button1.Enabled = false;
button2.Enabled = false;
button3.Enabled = true;
button4.Enabled = false;
}
change h1, h2, h3, h4 and p, strong, ins。`{%hackmd @Junter0323/H14LvIwHu %}`
May 30, 2022:::success 共三層,每層 ≥ 2子classes 每一classes ≥ 1 var + 1 method 用word or pdf 印出 ::: ::: danger
Nov 1, 2021最新公告 :::success 完成作業ㄧ、二 ::: 上課平台 ::: info
Oct 28, 20211.每股盈餘 2.稀釋性 3.母公司淨利 4.本期淨利 5.非控制權益 6.營業利益 7.營業活動之淨現金 (現金流量表) 8.綜合損益 9.流動資產 10.資產總計 (網站)
Apr 20, 2021or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up