public void Create(AnimalTypeEnum animalType, string name) { switch (animalType) { case AnimalTypeEnum.Cat: _animals.Add(new Cat(name)); break; case AnimalTypeEnum.Lion: _animals.Add(new Lion(name)); break; case AnimalTypeEnum.Dog: _animals.Add(new Dog(name)); break; case AnimalTypeEnum.Wolf: _animals.Add(new Wolf(name)); break; case AnimalTypeEnum.Mouse: _animals.Add(new Mouse(name)); break; case AnimalTypeEnum.Rat: _animals.Add(new Rat(name)); break; default: _cli.DisplayError($"No such type."); break; } _cli.DisplayInfo($"Created {animalType} with name {name}."); }
public void GoToSleep(string name) { if (!ValidateExistenceOfAnimal(name)) { _cli.DisplayError($"{name} doesn't exist."); return; } var animal = GetAnimalByName(name); animal.GoSleep(); _cli.DisplayInfo($"{animal.Name} is well rested."); }
static void Main(string[] args) { while (true) { var userInput = Console.ReadLine(); var userInputSplited = userInput.Split(CommonConstants.Whitespace); var command = userInputSplited.First(); var commandFirstParameter = userInputSplited.Length > 1 ? userInputSplited[1] : String.Empty; var commandSecondParameter = userInputSplited.Length > 2 ? userInputSplited[2] : String.Empty; switch (command) { case CliCommands.CreateCommand: var animalType = CommandParser.GetAnimalTypeFromParameter(commandFirstParameter); Lab.Create(animalType, commandSecondParameter); break; case CliCommands.GoToSleepCommand: Lab.GoToSleep(commandFirstParameter); break; case CliCommands.GoEatCommand: Lab.GoEat(commandFirstParameter); break; case CliCommands.BarkerCommand: Lab.Barker(commandFirstParameter); break; case CliCommands.PurrerCommand: Lab.Purrer(commandFirstParameter); break; case CliCommands.SqueakerCommand: Lab.Squeaker(commandFirstParameter); break; case CliCommands.ListCommand: Lab.ListAnimals(); break; case CliCommands.DeleteCommand: Lab.Delete(commandFirstParameter); break; default: Cli.DisplayError("Unknown command"); break; } } }