예제 #1
0
        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();
        }
예제 #2
0
파일: Program.cs 프로젝트: lilLink/Lab2
        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();
        }