public int check(Kuji kuji) { int kingaku = 0; if (kuji.Number == rank1) { kuji.Kekka = "1等"; kingaku = 10000; } else if (kuji.Number % 10000 == rank2) { kingaku = 1000; kuji.Kekka = "2等"; } else if (kuji.Number % 100 == rank3) { kingaku = 100; kuji.Kekka = "3等"; } else { kuji.Kekka = "外れ"; } this.Total += kingaku; return(kingaku); }
private void Button1_Click(object sender, EventArgs e) { int number; if (int.TryParse(textBox1.Text, out number)) { Kuji kuji = new Kuji(number); int kingaku = checker.check(kuji); Form2 form2 = new Form2(); form2.kekka = kuji.Kekka; form2.kingaku = kingaku; form2.ShowDialog(); labelTotal.Text = checker.Total + "円"; textBox1.Text = ""; } else { MessageBox.Show("数字を入力してください"); } }