Exemple #1
0
        public override bool Equals(object obj)
        {
            if (obj is Magazine)
            {
                Magazine other = (Magazine)obj;
                if (this.Name == other.Name && this.No == other.No)
                {
                    return(true);
                }
            }

            return(false);
        }
Exemple #2
0
        static void Main()
        {
            // Издатель.
            MicrosoftPress publisher = new MicrosoftPress();

            // Подписчики.
            Subscriber subscriber1 = new Subscriber(publisher, "Ivan");
            Subscriber subscriber2 = new Subscriber(publisher, "Anton");
            Subscriber subscriber3 = new Subscriber(publisher, "Alex");
            Subscriber subscriber4 = new Subscriber(publisher, "Serg");
            Subscriber subscriber5 = new Subscriber(publisher, "Igor");

            //-------------- 1-й выпуск журнала ----------------

            // Добавление подписчиков.
            publisher.AddToClientList(subscriber1);
            publisher.AddToClientList(subscriber2);
            publisher.AddToClientList(subscriber3);
            publisher.AddToClientList(subscriber4);

            Magazine magazine = new Magazine();

            magazine.Title   = "msdn";
            magazine.Content = "ASP.NET: Устранение проблем в приложениях с помощью журналов IIS  ... ";

            publisher.Magazine = magazine;
            publisher.SendMagazineToClient();

            Console.WriteLine(new string('-', 70));

            //-------------- 2-й выпуск журнала ----------------

            // Добавление нового подписчика.
            publisher.AddToClientList(subscriber5);
            // Удаление существующего подписчика.
            publisher.DeleteFromClientList(subscriber2);

            magazine         = new Magazine();
            magazine.Title   = "msdn";
            magazine.Content = "SQL Server: Модульное тестирование кубов OLAP в SQL Server с помощью C# ...";

            publisher.Magazine = magazine;
            publisher.SendMagazineToClient();

            Console.WriteLine(new string('-', 70));

            //-------------- N-й выпуск журнала ----------------

            // Задержка.
            Console.ReadKey();
        }
 public abstract void SetMagazine(Magazine magazine);
 public void SetMagazine(Magazine magazine)
 {
     this.magazine = magazine;
     magazine.AddSubscriber(this);
 }
 //constructor-2
 // GoldUser goldUser = new GoldUser(userName,magazine);
 public GoldUser(string userName, Magazine magazine)
 {
     this.userName = userName;
     this.magazine = magazine;
     magazine.AddSubscriber(this);
 }
        //private Magazine magazine; inherited from User class
        // private string userName;  inherited from User class
        #endregion


        #region constructor
        //constructor-1
        // GoldUser goldUser = new GoldUser(magazine); UserName eksik
        public GoldUser(Magazine magazine)
        {
            this.magazine = magazine;
            magazine.AddSubscriber(this);
            this.userName = "";
        }
Exemple #7
0
 public override void Deliver()
 {
     magazine = publisher.Magazine;
     Console.WriteLine("Подписчик {0} получил журнал: {1} со статьей: \n {2}",
                       name, magazine.Title, magazine.Content);
 }