public override bool Equals(object obj) { if (obj.GetType() != this.GetType()) { return(false); } PrintEdition print = (PrintEdition)obj; return(this.NameOfEdition == print.NameOfEdition); }
static void Main(string[] args) { PrintEdition printEdition1 = new PrintEdition("Book"); Book book1 = new Book("Harry Potter and the Prisoner of Azkaban", "United Kingdom", 1999, 464, "hard"); Author author1 = new Author("Joanne", "Rowling"); Publishing publishing1 = new Publishing("Bloomsbury"); PrintEdition printEdition2 = new PrintEdition("Magazin"); Magazin magazin2 = new Magazin("Vogue", "USA", 1998, 73, "soft"); Author author2 = new Author("Alena", "Doletskaya"); Publishing publishing2 = new Publishing("Condé Nast"); PrintEdition printEdition3 = new PrintEdition("School Book"); SchoolBook schoolBook3 = new SchoolBook("Upstream: Elementary A2 Student's Book", "United Kingdom", 2005, 128, "soft"); Author author3 = new Author("Virginia", "Evans"); Publishing publishing3 = new Publishing("Express Publishing"); Printer Printer = new Printer(); Object[] arr = new Object[] { printEdition1, book1, author1, publishing1, printEdition2, magazin2, author2, publishing2, printEdition3, schoolBook3, author3, publishing3 }; for (int i = 0; i < arr.Length; i++) { Console.WriteLine(Printer.IAmPrinting(arr[i])); Console.WriteLine(); } author1.Comment(); publishing3.Comment(); Console.WriteLine(); Console.Write(author1.Name + " " + author1.Surname); if (author1 is ICommentable) { Console.WriteLine(" is a very famous author"); } else { Console.WriteLine("is a начинающий автор"); } Console.WriteLine(); printEdition1.Equals(magazin2); }