Пример #1
0
        static void thread(PokojZabawek room)
        {
            room.Zabawki.AddEvent     += DodanoZabawke;
            room.Zabawki.LimitReached += OsiagnietoLimit;

            Random rand = new Random();

            for (int i = 0; i < 1000; i++)
            {
                int a = rand.Next(0, 2);
                switch (a)
                {
                case 0:
                    Car car = new Car("car #" + i, WzrosrWartosci);
                    room.Zabawki.Add(car);
                    break;

                case 1:
                    Box box = new Box("box #" + i, WzrosrWartosci);
                    room.Zabawki.Add(box);
                    break;

                case 2:
                    room.Zabawki.RemoveAt(0);
                    break;

                default:
                    break;
                }
            }
        }
Пример #2
0
        static void test2()
        {
            PokojZabawek room = new PokojZabawek();

            Thread th1 = new Thread(() => thread(room));
            Thread th2 = new Thread(() => thread(room));
            Thread th3 = new Thread(() => thread(room));

            th1.Start();
            th2.Start();
            th3.Start();

            th1.Join();
            th2.Join();
            th3.Join();
        }
Пример #3
0
        static void test1()
        {
            PokojZabawek room = new PokojZabawek();

            room.Zabawki.AddEvent     += DodanoZabawke;
            room.Zabawki.LimitReached += OsiagnietoLimit;

            Car audi         = new Car("Audi A4", WzrosrWartosci);
            Box chocolateBox = new Box("Chocolate", WzrosrWartosci);

            audi.WartoscBazowa.wzrostWartosciEvent         += WzrosrWartosci;
            chocolateBox.WartoscBazowa.wzrostWartosciEvent += WzrosrWartosci;

            room.Zabawki.Add(audi);
            room.Zabawki.Add(chocolateBox);

            room.pokazZabawki();

            audi.Accelerate   = 5;
            chocolateBox.Dive = 3;
            chocolateBox.Rise = 7;

            room.pokazZabawki();

            room.Zabawki.Add(new Car("Czolg", WzrosrWartosci));
            room.Zabawki.Add(new Car("Czolg", WzrosrWartosci));
            room.Zabawki.Add(new Car("Czolg", WzrosrWartosci));
            room.Zabawki.Add(new Car("Czolg", WzrosrWartosci));
            room.Zabawki.Add(new Car("Czolg", WzrosrWartosci));

            Wartosc w = audi.WartoscBazowa;

            w.Cena = 100;

            room.setAccelerate(3);
            room.setDive(4);
            room.setRise(7);
        }