Beispiel #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            SE         engineer   = new SE();
            Instrument instrument = null;

            //设置选中的乐器
            if (this.radioButton1.Checked)
            {
                instrument     = new Piano();
                groupBox1.Text = Name;
                MessageBox.Show("钢琴在演奏!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (this.radioButton2.Checked)
            {
                instrument     = new Violin();
                groupBox1.Text = Name;
                MessageBox.Show("小提琴在演奏!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else if (this.radioButton3.Checked)
            {
                instrument     = new Sachs();
                groupBox1.Text = Name;
                MessageBox.Show("萨克斯在演奏!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            engineer.Play();
        }