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;
- using System.Threading;
- namespace Aqua
- {
- class Program
- {
- static void Main(string[] args)
- {
- Aquarium aquarium = new Aquarium();
- bool runProgram = true;
- while (runProgram)
- {
- Thread.Sleep(1000);
- Console.Write('S');
- if (Console.KeyAvailable)
- {
- ConsoleKeyInfo key = Console.ReadKey(true);
- switch (key.Key)
- {
- case ConsoleKey.D0:
- break;
- case ConsoleKey.I:
- Console.WriteLine("Введите вид рыбы, которую хотите добавить ");
- int speciesIndex = Convert.ToInt32(Console.ReadLine());
- aquarium.AddFish(Fisher.OrderFish(speciesIndex));
- break;
- case ConsoleKey.R:
- Console.WriteLine("Введите номер рыбы, которую необходимо убрать ");
- int fishIndex = Convert.ToInt32(Console.ReadLine());
- aquarium.RemoveFish(fishIndex);
- break;
- case ConsoleKey.E:
- runProgram = false;
- break;
- }
- }
- }
- }
- static class Fisher
- {
- private static string[] _speciesName = new string[] {
- "Окунь", "Сом", "Анчоус"
- };
- private static int[] _speciesAge = new int[] { 10, 20, 12 };
- public static Fish OrderFish(int speciesIndex)
- {
- int age;
- int maxAge;
- Random rand = new Random();
- maxAge = _speciesAge[speciesIndex];
- age = rand.Next(maxAge);
- return new Fish(_speciesName[speciesIndex], age, maxAge);
- }
- }
- class Fish
- {
- private int _age;
- private int _maxAge;
- private string _speciesName;
- public Fish(string speciesName, int age, int maxAge)
- {
- _speciesName = speciesName;
- _age = age;
- _maxAge = maxAge;
- }
- }
- class Aquarium
- {
- private Fish[] _fishes;
- public Aquarium()
- {
- _fishes = new Fish[] { };
- }
- public void AddFish(Fish fish)
- {
- }
- public void RemoveFish(int fishIndex)
- {
- }
- public void ShowInfo()
- {
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment