Esempio n. 1
0
        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();
        }
Esempio n. 2
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();
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            Magazine       m        = new Magazine();
            List <Article> articles = new List <Article> {
                new Article()
            };
            List <Person> editors = new List <Person> {
                new Person()
            };

            m.addArticles(articles);
            m.addEditors(editors);
            Console.WriteLine(m.ToShortString());
            Console.WriteLine(m.ToString());
            Console.ReadLine();
        }