private void btnRefill_Click(object sender, EventArgs e) //Обработчик кнопки "Перезаполнить" { this.drinksList.Clear(); var rnd = new Random(); for (var i = 0; i < 15; ++i) { switch (rnd.Next() % 3) // генерирую случайное число от 0 до 2 для выбора напитка { case 0: this.drinksList.Add(Juice.Generate()); break; case 1: this.drinksList.Add(Soda.Generate()); break; case 2: this.drinksList.Add(Alcohol.Generate()); break; } } ShowInfo(); }
static void Main(string[] args) { Person person = new Person() { Name = "Чолкан", Surname = "Роман", Age = 20 }; Person person1 = new Person() { Name = "Соломія", Surname = "Сорокотяга", Age = 20 }; Juice juice = new Juice() { Name = "Наш сiк", Owner = person }; Cup <Drink> cup = new Cup <Drink>() { Name = "Улюблене рожеве горнятко", Owner = person }; if (juice.CheckForCorrectOwner(person)) { cup.PutSomeDrinkIn(juice, person); } if (juice.CheckForCorrectOwner(person1)) { cup.PutSomeDrinkIn(juice, person1); } Console.ReadLine(); }