Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- namespace AtTheZoo
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.WriteLine("Welcome to the zoo!");
- List<Enclosure> enclosureList = new List<Enclosure>
- {
- new Enclosure("Ostrich farm", 10, "female", "UA-UA-UA!"),
- new Enclosure("Monkey cage", 7, "male", "A-A-A!"),
- new Enclosure("Crocodile river", 15, "male", "Psst"),
- new Enclosure("Lions pride", 4, "female", "Arggh!")
- };
- Console.WriteLine("Выберите к какому вольеру подойти:");
- foreach (var item in enclosureList)
- {
- Console.WriteLine(item.Name);
- }
- int userInput = Convert.ToInt32(Console.ReadLine());
- switch (userInput)
- {
- case 1:
- enclosureList[userInput - 1].showInformation(userInput, enclosureList);
- break;
- case 2:
- enclosureList[userInput - 1].showInformation(userInput, enclosureList);
- break;
- case 3:
- enclosureList[userInput - 1].showInformation(userInput, enclosureList);
- break;
- case 4:
- enclosureList[userInput - 1].showInformation(userInput, enclosureList);
- break;
- }
- }
- }
- class Enclosure
- {
- public string Name;
- public int AnimalsAmount;
- public string Sex;
- public string Sound;
- public Enclosure(string name, int amount, string sex, string sound)
- {
- Name = name;
- AnimalsAmount = amount;
- Sex = sex;
- Sound = sound;
- }
- public void showInformation(int enclosureNumber, List<Enclosure> enclosures)
- {
- Console.WriteLine($"Название: {enclosures[enclosureNumber - 1].Name} \nКоличество животных: {enclosures[enclosureNumber - 1].AnimalsAmount} \nПол: {enclosures[enclosureNumber - 1].Sex} \nВы слышите звук: {enclosures[enclosureNumber - 1].Sound}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement