static void Main(string[] args) { //no inheritance needed, but an interface will be needed //create classes that represent animals that makes sounds, what is the animal and what sound does it make Cat cat = new Cat(); Dog dog = new Dog(); Chicken chicken = new Chicken(); Rooster rooster = new Rooster(); Horse horse = new Horse(); Pig pig = new Pig(); Duck duck = new Duck(); Cow cow = new Cow(); Sheep sheep = new Sheep(); Piano piano = new Piano(); //put all animals in a collection IAnimalSounds[] animals = { cat, dog, chicken, rooster, horse, pig, duck, cow, sheep, piano }; foreach (IAnimalSounds animal in animals) { string animalName = animal.GetAnimalName(); string animalSound = animal.GetAnimalSound(); //return message: "The animal "" makes the sound """ string message = $"A {animalName} says {animalSound}."; Console.WriteLine(message); } Console.ReadKey(); //goal of the program is to output the animals that make sounds }
static void Main(string[] args) { Dog dog = new Dog(); Elephant elephant = new Elephant(); Monkey monkey = new Monkey(); Cat cat = new Cat(); Cow cow = new Cow(); Chicken chicken = new Chicken(); Pig pig = new Pig(); Lion lion = new Lion(); Hyena hyena = new Hyena(); Horse horse = new Horse(); ISounds[] animals = { dog, elephant, monkey, cat, cow, chicken, pig, lion, hyena, horse }; foreach (ISounds animal in animals) { string animalName = animal.GetName(); string animalSound = animal.GetSound(); string message = $"A(n) {animalName} says {animalSound}."; Console.WriteLine(message); } Console.ReadKey(); }