public static void AddAnimal(Component Aviary) { Creator cr5; Random rnd = new Random(); int animalnum = rnd.Next(1, 100); ShowType(animalnum); Console.Write("Enter name: "); string name = Console.ReadLine(); Console.Write("Enter weight: "); int weight = Convert.ToInt32(Console.ReadLine()); if (animalnum < 40) { cr5 = new WolfCreator(name, weight); } else if (animalnum >= 40 && animalnum < 80) { cr5 = new BearCreator(name, weight); } else { cr5 = new GiraffeCreator(name, weight); } Animal animal5 = cr5.Add(cr5.Name, cr5.Weight); Console.WriteLine(animal5.AddMsg().ToString()); Aviary.Add(animal5); }
public static void LoadAnimals(Component Aviary) { Creator cr = new BearCreator("Ben", 300); Animal animal1 = cr.Add(cr.Name, cr.Weight); Console.WriteLine(animal1.AddMsg().ToString()); Aviary.Add(animal1); Creator cr2 = new GiraffeCreator("Buch", 300); Animal animal2 = cr2.Add(cr2.Name, cr2.Weight); Console.WriteLine(animal2.AddMsg().ToString()); Aviary.Add(animal2); }