Пример #1
0
        private void btnCreate_Click(object sender, EventArgs e)
        {
            Random gen = new Random();

            if (radDog.Checked == true)
            {
                Gender random = (Gender)gen.Next((int)Gender.Male, (int)Gender.Unknown + 1);
                Animal doggo1 = new Dog();

                doggo1.name   = Interaction.InputBox("Enter your dog's name");
                doggo1.color  = Interaction.InputBox("Enter your dog's color");
                doggo1.weight = Convert.ToDouble(Interaction.InputBox("Enter your dog's weight"));
                doggo1.gender = random;

                lblOutput.Text += doggo1.ToString();
                doggo1.Noise();
            }
            else if (radCat.Checked == true)
            {
                Gender random = (Gender)gen.Next((int)Gender.Male, (int)Gender.Unknown + 1);
                Animal cato1  = new Cat();

                cato1.name   = Interaction.InputBox("Enter your cat's name");
                cato1.color  = Interaction.InputBox("Enter your cat's color");
                cato1.weight = Convert.ToDouble(Interaction.InputBox("Enter your cat's weight"));
                cato1.gender = random;

                lblOutput.Text += cato1.ToString();
                cato1.Noise();
            }
            else if (radBird.Checked == true)
            {
                Gender random = (Gender)gen.Next((int)Gender.Male, (int)Gender.Unknown + 1);
                Animal birb1  = new Bird();

                birb1.name   = Interaction.InputBox("Enter your bird's name");
                birb1.color  = Interaction.InputBox("Enter your bird's color");
                birb1.weight = Convert.ToDouble(Interaction.InputBox("Enter your bird's weight"));
                birb1.gender = random;

                lblOutput.Text += birb1.ToString();
                birb1.Noise();
            }
        }