public static void Main(string[] args) { Edition first = new Edition(); Edition second = new Edition(); Console.WriteLine("==: " + (first == second)); Console.WriteLine("Equals: " + first.Equals(second)); Console.WriteLine("GetHashCode: " + first.GetHashCode() + " " + second.GetHashCode()); Console.WriteLine("\nException: "); try { first.EditionCirculation = -1; } catch (Exception e) { Console.WriteLine(e.Message); } Console.WriteLine("\nAdd Articles and Editors: "); Magazine magazine = new Magazine(); magazine.AddArticles(new Article(), new Article()); magazine.AddEditors(new Person(), new Person()); Console.WriteLine(magazine); Console.WriteLine("\nShow Edition from Magazine: "); Console.WriteLine(magazine.EditionBase); Console.WriteLine("\nDeepCopy : "); Magazine magazineCopy = (Magazine)magazine.DeepCopy(); magazine.MagazineName = "Original"; Console.WriteLine(magazine.MagazineName + " != " + magazineCopy.MagazineName); double moreThan = 10; Console.WriteLine("\nforeach ArticleRage more than " + moreThan + " : "); ((Article)magazine.ArticleList[0]).ArticleRage = 12; foreach (var article in magazine.GetArticlesMoreThan(moreThan)) { Console.WriteLine(article); } string searchText = "New"; Console.WriteLine("\nforeach ArticleName with " + searchText + " : "); foreach (var article in magazine.GetArticlesWithText(searchText)) { Console.WriteLine(article); } Magazine magazine2 = new Magazine(); Console.WriteLine(magazine2.ToString()); Console.ReadKey(); }
static void Main(string[] args) { Edition ed1 = new Edition("Hello", new DateTime(2018, 09, 10), 3); Edition ed2 = new Edition("Hello", new DateTime(2018, 09, 10), 3); Console.WriteLine(ed1 == ed2); Console.WriteLine(ed1.GetHashCode() + "\n" + ed2.GetHashCode() + '\n'); try { ed1.Circulation = -1; } catch (Exception ex) { Console.WriteLine(ex.Message); } Magazine magazine = new Magazine(); Article[] article = new Article[3]; article[0] = new Article(new Person("Tess", "Geritsen", new DateTime(1990, 10, 6)), "Fire!", 4.2); article[1] = new Article(new Person("Lion", "Getenberg", new DateTime(1995, 6, 13)), "Vegetables can go!", 4.8); article[2] = new Article(new Person("Jey", "Hirston", new DateTime(1997, 11, 24)), "Fruits can go!", 4.0); magazine.AddArticle(article); Person[] editors = new Person[3]; editors[0] = new Person("Tony", "Stark", new DateTime(1990, 10, 6)); editors[1] = new Person("Natasha", "Roman", new DateTime(1990, 10, 6)); editors[2] = new Person("Black", "widow", new DateTime(1990, 10, 6)); magazine.AddEditors(editors); Console.WriteLine(magazine.ToString()); Console.WriteLine(magazine.EditionBase); Magazine magazine1 = new Magazine(); magazine1 = (Magazine)magazine.DeepCopy(); magazine.Circulation = 10; magazine.Name = "Tania"; Console.WriteLine("Original:\n" + magazine.ToString()); Console.WriteLine("Copy:\n" + magazine1.ToString()); Console.WriteLine("Hello \n"); foreach (Article art in magazine.GetArticle(4.0F)) { Console.WriteLine(art); } Console.WriteLine("\n"); foreach (Article art in magazine.ContainWord("can")) { Console.WriteLine(art); } Console.ReadLine(); }
static void Main(string[] args) { Edition edition1 = new Edition("NY Times", new DateTime(2000, 09, 02), 300); Edition edition2 = new Edition("NY Times", new DateTime(2000, 09, 02), 300); Console.WriteLine("Рівність посилань : " + Object.ReferenceEquals(edition1, edition2)); Console.WriteLine("Рівність об'єктів: " + (edition1 == edition2)); try { edition1.CopiesCount = -100; } catch (ArgumentException exception) { Console.WriteLine(exception.Message); } Magazine magazine = new Magazine("Daily Bugles", Frequency.Monthly, new DateTime(2010, 12, 12), 250000); magazine.AddArticles(new Article(new Person("Nick", "Back", new DateTime(1990, 10, 20)), "Corona-Time", 2.2)); magazine.AddEditors(new Person("Kek", "lol", new DateTime(1988, 8, 7))); Magazine magazineCopy = (Magazine)magazine.DeepCopy(); magazineCopy.CopiesCount = 1; Console.WriteLine("Original: " + magazine); Console.WriteLine("Copy: " + magazineCopy); foreach (Article article in magazine.ArticlesMoreThan(2)) { Console.WriteLine(article); } foreach (Article article in magazine.ArticlesWithName("Corona")) { Console.WriteLine(article); } Console.Read(); }