public string Adopt(string animalName, string owner) { if (!this.hotel.Animals.ContainsKey(animalName)) { throw new ArgumentException($"Animal {animalName} does not exist"); } this.animal = this.hotel.Animals.First(a => a.Key == animalName).Value; if (!this.AdoptedAnimals.ContainsKey(owner)) { this.AdoptedAnimals.Add(owner, new List <IAnimal>()); this.AdoptedAnimals[owner].Add(animal); } else { this.AdoptedAnimals[owner].Add(animal); } hotel.Adopt(this.animal.Name, owner); if (this.animal.IsChipped) { return($"{owner} adopted animal with chip"); } return($"{owner} adopted animal without chip"); }
public string Adopt(string animalName, string owner) { IAnimal animal = GetAnimal(animalName); hotel.Adopt(animalName, owner); if (!this.adoptedAnimals.ContainsKey(owner)) { this.adoptedAnimals.Add(owner, new List <IAnimal>()); } this.adoptedAnimals[owner].Add(animal); if (animal.IsChipped) { return($"{owner} adopted animal with chip"); } return($"{owner} adopted animal without chip"); }
public string Adopt(string animalName, string ownerName) { var animal = hotel.Animals[animalName]; hotel.Adopt(animalName, ownerName); if (!adoptedAnimals.ContainsKey(ownerName)) { adoptedAnimals.Add(ownerName, new List <string>()); adoptedAnimals[ownerName].Add(animalName); } else { adoptedAnimals[ownerName].Add(animalName); } return(animal.IsChipped == true ? $"{ownerName} adopted animal with chip" : $"{ownerName} adopted animal without chip"); }
public string Adopt(string animalName, string owner) { var animal = hotel.Animals[animalName]; if (animal == null) { throw new ArgumentException(string.Format(Message_Animal_Donot_Exist, animalName)); } hotel.Adopt(animalName, owner); AddInAdoptedData(animal); if (animal.IsChipped) { return($"{owner} adopted animal with chip"); } return($"{owner} adopted animal without chip"); }