Ejemplo n.º 1
0
        /// <summary>
        /// Show Bloger Events Method
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Blogger_Event(object sender, EventArgs e)
        {
            if (e is Create_New_Event)
            {
                Create_New_Event AAAAA = e as Create_New_Event;

                if (AAAAA.For_Adult_Onely == true && Age < 18)
                {
                    Console.WriteLine("==================================");
                    Console.WriteLine("\n\t\t Hello {0}!!!", Name);
                    Console.WriteLine("\t {0}", AAAAA.Title);
                    Console.WriteLine("\n\t Event only for adult!!!\n");
                    Console.WriteLine("==================================");
                }

                else
                {
                    Console.WriteLine("\n\n\n\t\t Hello {0}!!!", Name);
                    Console.WriteLine("\n Bloger {0} just created new event!", Bloger_Name);
                    Console.WriteLine("\n\n\t {0}", AAAAA.Title);
                    Console.WriteLine("\t Data: {0}", AAAAA.Event_Date);
                    if (AAAAA.For_Adult_Onely)
                    {
                        Console.WriteLine("\t Only for adult!!!");
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public event EventHandler Subscribers; //Przechwytuje subskrybentów
        //EventHandler - to składowa .Net, która odpowiada za to, żeby obiekty które nasłuchują
        //mógł prawidłowo obsłużyć zdarzenie które zaistniało

        public void Show_Subscribers_Event(Create_New_Event EEE)
        {
            EventHandler Event_Subscribers = Subscribers;

            if (Event_Subscribers != null)    //Sprawdzenie czy sa jacys subskrybenci
            {
                Event_Subscribers(this, EEE); //Jesli ktos nasluchuje wysyla mu dane
            }
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            //Create bloggers
            Blogger AAA = new Blogger("Piotr", 22, "Piłka nożna");
            Blogger BBB = new Blogger("Beata", 18, "Architektura");
            Blogger CCC = new Blogger("Agnieszka");
            Blogger DDD = new Blogger("Grzesiek");
            Blogger EEE = new Blogger("Krzysiek", 16, "Projektowanie wnetrz");

            //create subscribers
            Subscriber A = new Subscriber("Piotr", 22, "Piłka nożna");
            Subscriber B = new Subscriber("Beata", 55, "Agregaty");
            Subscriber C = new Subscriber("Aga", 14, "Łowiectwo");
            Subscriber D = new Subscriber("Booler", 33, "Grzyby");
            Subscriber E = new Subscriber("Beata", 66, "Projekty ubrań");
            Subscriber F = new Subscriber("Beata");
            Subscriber G = new Subscriber("Gacek");

            //Subscribe bloggers by subscribers
            A.Subscribe_Blogger(AAA);
            A.Subscribe_Blogger(CCC);
            A.Subscribe_Blogger(EEE);
            B.Subscribe_Blogger(AAA);
            G.Subscribe_Blogger(CCC);
            D.Subscribe_Blogger(EEE);
            A.Subscribe_Blogger(AAA);
            A.Subscribe_Blogger(CCC);
            A.Subscribe_Blogger(EEE);
            C.Subscribe_Blogger(AAA);
            C.Subscribe_Blogger(CCC);
            C.Subscribe_Blogger(EEE);
            F.Subscribe_Blogger(AAA);
            F.Subscribe_Blogger(CCC);
            F.Subscribe_Blogger(EEE);
            E.Subscribe_Blogger(AAA);
            E.Subscribe_Blogger(CCC);
            C.Subscribe_Blogger(EEE);
            G.Subscribe_Blogger(AAA);
            G.Subscribe_Blogger(CCC);
            G.Subscribe_Blogger(EEE);

            //Create new events
            Create_New_Event Event1 = new Create_New_Event("Free coffe", true, "12.01.2018", 230);
            Create_New_Event Event2 = new Create_New_Event("News!!!", true, "12.12.2019", 15);
            Create_New_Event Event3 = new Create_New_Event("Informations", true, "6.6.2018", 22);
            Create_New_Event Event4 = new Create_New_Event("New video", false, "1.01.2018", 280);
            Create_New_Event Event5 = new Create_New_Event("Free time", false, "2.01.2018", 240);

            AAA.Show_Subscribers_Event(Event1);
            AAA.Show_Subscribers_Event(Event2);
            AAA.Show_Subscribers_Event(Event3);
            AAA.Show_Subscribers_Event(Event4);

            CCC.Show_Subscribers_Event(Event1);
            CCC.Show_Subscribers_Event(Event2);
            CCC.Show_Subscribers_Event(Event3);
            CCC.Show_Subscribers_Event(Event4);
            CCC.Show_Subscribers_Event(Event5);

            Console.ReadLine();
        }