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.Text;
- using System.Threading.Tasks;
- namespace Animal
- {
- class Program
- {
- static void Main(string[] args)
- {
- var dogs = new Dictionary<string, Dog>();
- var cats = new Dictionary<string, Cat>();
- var snakes = new Dictionary<string, Snake>();
- string input = Console.ReadLine();
- while (input != "I'm your Huckleberry")
- {
- string[] inputTokens = input.Split(' ');
- string type = inputTokens[0];
- string name = inputTokens[1];
- if (type == "talk")
- {
- if (dogs.ContainsKey(name))
- {
- dogs[name].ProduceSound();
- }
- if (cats.ContainsKey(name))
- {
- cats[name].ProduceSound();
- }
- if (snakes.ContainsKey(name))
- {
- snakes[name].ProduceSound();
- }
- }
- if (type == "Dog")
- {
- name = inputTokens[1];
- int age = int.Parse(inputTokens[2]);
- int property = int.Parse(inputTokens[3]);
- dogs.Add(name, new Dog(name, age, property));
- }
- else if (type == "Cat")
- {
- name = inputTokens[1];
- int age = int.Parse(inputTokens[2]);
- int property = int.Parse(inputTokens[3]);
- cats.Add(name, new Cat(name, age, property));
- }
- else if (type == "Snake")
- {
- name = inputTokens[1];
- int age = int.Parse(inputTokens[2]);
- int property = int.Parse(inputTokens[3]);
- snakes.Add(name, new Snake(name, age, property));
- }
- input = Console.ReadLine();
- }
- foreach (var item in dogs)
- {
- Dog dog = item.Value;
- Console.WriteLine($"Dog: {dog.Name}, Age: {dog.Age}, Number Of Legs: {dog.NumberOfLegs}");
- }
- foreach (var item in cats)
- {
- Cat cat = item.Value;
- Console.WriteLine($"Cat: {cat.Name}, Age: {cat.Age}, IQ: {cat.IntelligenceQuotient}");
- }
- foreach (var item in snakes)
- {
- Snake snake = item.Value;
- Console.WriteLine($"Snake: {snake.Name}, Age: {snake.Age}, Cruelty: {snake.CrueltyCoefficient}");
- }
- }
- class Dog
- {
- public string Name { get; set; }
- public int Age { get; set; }
- public int NumberOfLegs { get; set; }
- public Dog(string name, int age, int property)
- {
- this.Name = name;
- this.Age = age;
- this.NumberOfLegs = property;
- }
- public void ProduceSound()
- {
- Console.WriteLine("I'm a Distinguishedog, and I will now produce a distinguished sound! Bau Bau.");
- }
- }
- class Cat
- {
- public string Name { get; set; }
- public int Age { get; set; }
- public int IntelligenceQuotient { get; set; }
- public void ProduceSound()
- { Console.WriteLine("I'm an Aristocat, and I will now produce an aristocratic sound! Myau Myau."); }
- public Cat(string name, int age, int property)
- {
- this.Name = name;
- this.Age = age;
- this.IntelligenceQuotient = property;
- }
- }
- class Snake
- {
- public string Name { get; set; }
- public int Age { get; set; }
- public int CrueltyCoefficient { get; set; }
- public Snake(string name, int age, int property)
- {
- this.Name = name;
- this.Age = age;
- this.CrueltyCoefficient = property;
- }
- public void ProduceSound()
- { Console.WriteLine("I'm a Sophistisnake, and I will now produce a sophisticated sound! Honey, I'm home."); }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement