static void Main(string[] args) { try { Album a = new Album("Tristan Prettyman", "Hello...x", 2007, 14, eFileType.MP3); Album b = new Album("Tommy Stinson", "One Man Mutiny", 2011, 10, eFileType.FLAC); Album c = new Album("The Palms", "Untitled", 2013, 6, eFileType.WEBM); Console.WriteLine($"Album: {a.ArtistName}, {a.AlbumTitle}, {a.ReleaseYear}, {a.NumOfTracks}, {a.FileType}; age: {a.AlbumAge()} years"); Console.WriteLine($"Album: {b.ArtistName}, {b.AlbumTitle}, {b.ReleaseYear}, {b.NumOfTracks}, {b.FileType}; age: {b.AlbumAge()} years"); Console.WriteLine($"Album: {c.ArtistName}, {c.AlbumTitle}, {c.ReleaseYear}, {c.NumOfTracks}, {c.FileType}; age: {c.AlbumAge()} years"); // T3.4: create array of interface type, loop over the array: IVertebrate[] Vertebrate = new IVertebrate[8]; Vertebrate[0] = new Fish("Shark", eWaterType.salt); Vertebrate[1] = new Fish("Clown Fish", eWaterType.salt); Vertebrate[2] = new Fish("Scalare", eWaterType.sweet); Vertebrate[3] = new Fish("Plated Catfish", eWaterType.sweet); Vertebrate[4] = new Fish("Reedfish", eWaterType.brack); Vertebrate[5] = new Bird("Sparrow", eBirdSkills.canRunFly); Vertebrate[6] = new Bird("Ostrich", eBirdSkills.canRun); // = Strauss Vertebrate[7] = new Bird("Duck", eBirdSkills.canRunFlySwim); for (int index = 0; index < Vertebrate.Length; index++) { Console.WriteLine($"{Vertebrate[index].family}: {Vertebrate[index].species} ({Vertebrate[index].count})"); } } catch (Exception e) { Console.WriteLine($"Oops, something happened ({e.Message})"); } }
static void Main(string[] args) { try { Album a = new Album("Tristan Prettyman", "Hello...x", 2007, 14, eFileType.MP3); Album b = new Album("Tommy Stinson", "One Man Mutiny", 2011, 10, eFileType.FLAC); Album c = new Album("The Palms", "Untitled", 2013, 6, eFileType.WEBM); Console.WriteLine($"Album: {a.ArtistName}, {a.AlbumTitle}, {a.ReleaseYear}, {a.NumOfTracks}, {a.FileType}; age: {a.AlbumAge()} years"); Console.WriteLine($"Album: {b.ArtistName}, {b.AlbumTitle}, {b.ReleaseYear}, {b.NumOfTracks}, {b.FileType}; age: {b.AlbumAge()} years"); Console.WriteLine($"Album: {c.ArtistName}, {c.AlbumTitle}, {c.ReleaseYear}, {c.NumOfTracks}, {c.FileType}; age: {c.AlbumAge()} years"); // T3.4: create array of interface type, loop over the array: var Vertebrate = new IVertebrate[] { new Fish("Shark", eWaterType.salt), new Fish("Clown Fish", eWaterType.salt), new Fish("Scalare", eWaterType.sweet), new Fish("Plated Catfish", eWaterType.sweet), new Fish("Reedfish", eWaterType.brack), new Bird("Sparrow", eBirdSkills.canRunFly), new Bird("Ostrich", eBirdSkills.canRun), // = Strauss new Bird("Duck", eBirdSkills.canRunFlySwim), }; Console.WriteLine("\n\nAnimals:\n"); foreach (var x in Vertebrate) { Console.WriteLine($"{x.family}: {x.species} ({x.count})"); } SerializationExample.Run(Vertebrate); } catch (Exception e) { Console.WriteLine($"Oops, something happened ({e.Message})"); } }