public static void SearchForAnimal() { searchResults.Clear(); Console.WriteLine("Enter animal name"); string input = Console.ReadLine(); foreach (var animal in Animal.GetList()) { if (animal.AnimalName.ToLower() == input.ToLower() || animal.AnimalType.ToLower() == input.ToLower() || animal.Location.ToLower() == input.ToLower() || animal.LastSeen.ToLower() == input.ToLower()) { searchResults.Add(animal); } } if (searchResults.Count == 0) { Console.WriteLine("Sorry... No results."); Console.WriteLine("Try Again."); Console.WriteLine(); } foreach (Animal item in searchResults) { Console.WriteLine(); Console.WriteLine("Animal Name : {0}", item.AnimalName); Console.WriteLine("Animal Type : {0}", item.AnimalType); Console.WriteLine("Animal Location : {0}", item.Location); Console.WriteLine("Animal Last Seen : {0}", item.LastSeen); Console.WriteLine("Date Added : {0}", item.TimeCreated); System.Console.WriteLine(" - - - - - - - - - - - - - -"); System.Console.WriteLine(); } Main(); }
public static void PrintList() { foreach (Animal item in Animal.GetList()) { System.Console.WriteLine("- - - - - - - - -"); System.Console.WriteLine("Name : {0}", item.AnimalName); System.Console.WriteLine("Name : {0}", item.AnimalType); System.Console.WriteLine("Name : {0}", item.Location); System.Console.WriteLine("Name : {0}", item.LastSeen); System.Console.WriteLine(); System.Console.WriteLine("- - - - - - - - -"); } Main(); }
public static void AddAnimal() { Console.WriteLine("Enter animal name"); string animalName = Console.ReadLine(); Console.WriteLine("Enter animal type"); string animalKind = Console.ReadLine(); Console.WriteLine("Enter animal location"); string animalLocation = Console.ReadLine(); Console.WriteLine("Enter animal last seen"); string animalLastSeen = Console.ReadLine(); Animal animal = new Animal(animalName, animalKind, animalLocation, animalLastSeen); System.Console.WriteLine("Count of list = " + Animal.GetList().Count); Animal.AddToList(animal); Main(); }