Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Runtime.CompilerServices;
- namespace AtTheZoo
- {
- class Program
- {
- static void Main(string[] args)
- {
- Animal monkey1 = new Animal("Monkey", "Male", "O-o-O-o!");
- Animal monkey2 = new Animal("Monkey", "Female", "O-o-O-o!!");
- Animal tiger1 = new Animal("Tiger", "Male", "Rrrr!");
- Animal tiger2 = new Animal("Tiger", "Female", "Rrrr!");
- Animal hippo1 = new Animal("Hippo", "Female", "bulp-bulp!");
- Animal hippo2 = new Animal("Hippo", "Female", "bulp-bulp!");
- Animal hippo3 = new Animal("Hippo", "Female", "bulp-bulp!");
- Animal parrot = new Animal("Parrot", "Male", "chik-chirik!");
- List<Animal> monkeyList = new List<Animal>();
- monkeyList.Add(monkey1);
- monkeyList.Add(monkey2);
- Enclosure cage1 = new Enclosure("Monkey Cage", monkeyList);
- List<Animal> tigerList = new List<Animal>();
- tigerList.Add(tiger1);
- tigerList.Add(tiger2);
- Enclosure cage2 = new Enclosure("Tiger Cage", tigerList);
- List<Animal> hippoList = new List<Animal>();
- hippoList.Add(hippo1);
- hippoList.Add(hippo2);
- Enclosure cage3 = new Enclosure("Hippo's pool", hippoList);
- List<Animal> parrotList = new List<Animal>();
- parrotList.Add(parrot);
- Enclosure cage4 = new Enclosure("Parrot Cage", parrotList);
- List<Enclosure> enclosures = new List<Enclosure>();
- enclosures.Add(cage1);
- enclosures.Add(cage2);
- enclosures.Add(cage3);
- enclosures.Add(cage4);
- while (true)
- {
- Console.Clear();
- Console.WriteLine("Welcome to the zoo!");
- Console.WriteLine("Выберите к какому вольеру подойти:");
- int cageCount = 1;
- foreach (var item in enclosures)
- {
- Console.WriteLine($"[{cageCount}] - {item.Name}");
- cageCount++;
- }
- int userInput = Convert.ToInt32(Console.ReadLine()) - 1;
- enclosures[userInput].showInformation(userInput, enclosures);
- Console.ReadKey();
- }
- }
- }
- class Enclosure
- {
- public string Name { get; private set; }
- private List<Animal> _animals = new List<Animal>();
- public Enclosure(string name, List<Animal> animals)
- {
- _animals = animals;
- Name = name;
- }
- public void showInformation(int enclosureNumber, List<Enclosure> enclosures)
- {
- Console.WriteLine($"Название: {enclosures[enclosureNumber].Name}");
- Console.WriteLine($"\nКоличество животных:{enclosures[enclosureNumber]._animals.Count} ");
- Console.WriteLine($"\nПол:{enclosures[enclosureNumber]._animals[0].Sex}");
- Console.WriteLine($"\nВы слышите звук:{enclosures[enclosureNumber]._animals[0].Sound}");
- }
- }
- class Animal
- {
- public string Name { get; private set; }
- public string Sex { get; private set; }
- public string Sound { get; private set; }
- public Animal(string name, string sex, string sound)
- {
- Name = name;
- Sex = sex;
- Sound = sound;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement