Exemplo n.º 1
0
        public override void RunApp()
        {
            IOutputWritter writter = new ConsoleWritter();

            Weapon weapon = new Sword("Armageddon",999999, writter);
            weapon.Kill();
            weapon = new Bone("Kel To Zeth",17005, writter);
            weapon.Kill();
        }
Exemplo n.º 2
0
 /// <summary>
 /// Now we trying to uderstand pattern FactoryMethod
 /// </summary>
 public override void RunApp()
 {
     IOutputWritter writter = new ConsoleWritter();
     var factory = new DeathStarFactory();
     var deathStar = factory.CreateDeathStar("DarthVaderLoveHisMom", 10000, 2500);
     writter.WriteLine(deathStar.ToString());
     deathStar = factory.CreateDeathStar("BB Watson", 250, 125);
     writter.WriteLine(deathStar.ToString());
 }
Exemplo n.º 3
0
        /// <summary>
        /// In real case we need write too much
        /// <code>
        /// Car car = new Car()
        /// car.transmisson = N;
        /// car.engine = on;
        /// car.stereo = on;
        /// car.setvolume = 5;
        /// </code>
        /// </summary>
        public override void RunApp()
        {
            IOutputWritter writter = new ConsoleWritter();
            var car = new CarsFacade(new Engine(writter),new Stereo(writter), new Transmission(writter) );

            //but now - only 2 methods
            car.StrartMoving();
            writter.WriteLine("\n");
            car.StopMoving();
        }
Exemplo n.º 4
0
        public override void RunApp()
        {
            IOutputWritter writter = new ConsoleWritter();
            AbstractBehavior abstractBehavior = new Task("Send Me mail", "James", writter);
            abstractBehavior.Add(new TaskItem(DateTime.Now, "James willson"));
            abstractBehavior.Add(new TaskItem(DateTime.Now, "Gregory House"));
            abstractBehavior.Add(new Task("Get up server tasking", "Operation 'No steps back'", writter));

            abstractBehavior.GetSub();

            writter.WriteLine(abstractBehavior.ToString());
        }
Exemplo n.º 5
0
        public override void RunApp()
        {
            IOutputWritter writter = new ConsoleWritter();
            //Need for Speed !!!
            Car car = new BatmanCar();
            writter.WriteLine(car.GetDescription() + " " + car.Price());

            car = new TurboEngine(car);
            writter.WriteLine(car.GetDescription() + " " + car.Price());

            car = new FastTransmission(car);
            writter.WriteLine(car.GetDescription() + " " + car.Price());

            car = new AbSsystems(car);
            writter.WriteLine(car.GetDescription() + " " + car.Price());
        }
Exemplo n.º 6
0
        /// <summary>
        /// Create HQ and add some agent to it 
        /// When hq start new Operation "London Take Down"
        /// </summary>
        public override void RunApp()
        {
            IOutputWritter outputWritter = new ConsoleWritter();

            var hq = new HeadQuartes();
            IObserver jamesbond = new James("James Bond", outputWritter);
            IObserver tanyaRomanova = new Tanya("Romanova Tanya", outputWritter);

            hq.RegisterNewSpy(jamesbond);
            hq.RegisterNewSpy(tanyaRomanova);

            hq.ChangeOperation("London Take Down");
            hq.ChangeStatus("Active");

            hq.NotifyAllSpys();
            hq.AgentRepeat();
        }
Exemplo n.º 7
0
        public override void RunApp()
        {
            IOutputWritter writter = new ConsoleWritter();

            PostBehavior email = new Email(writter, "*****@*****.**", "*****@*****.**", "Today Lection");
            PostBehavior letter = new Letter(writter, "Mr Write. ", "Santa Claus. North Pole, str. MainHall 1");

            email.SendPost();
            writter.WriteLine("\n");
            writter.WriteLine(email.ToString());
            writter.WriteLine("\n");

            letter.SendPost();
            writter.WriteLine("\n");
            writter.WriteLine(letter.ToString());
            writter.WriteLine("\n");
        }
Exemplo n.º 8
0
        public override void RunApp()
        {
            IOutputWritter writter = new ConsoleWritter();
            var machine = new GumMachine(10, writter);

            machine.InsertPenny();
            machine.Turn();

            writter.WriteLine("\n");
            machine.InsertPenny();
            machine.EjectPenny();
            machine.EjectPenny();

            writter.WriteLine("\n");
            machine = new GumMachine(0, writter);
            machine.Turn();
            machine.InsertPenny();
        }
Exemplo n.º 9
0
        public override void RunApp()
        {
            IOutputWritter writter = new ConsoleWritter();
            ISmartPhone phone = new MySmartPhone(writter);
            IComputer computer = new MyHomeComputer(writter);

            phone.SwitchOn();
            phone.GoToInternet();
            phone.SwitchOff();

            computer.Hello();
            computer.RunBrowser();
            computer.SwitchOff();

            //now fun
            phone = new ComputerToPhoneAdapter((MyHomeComputer) computer);
            phone.SwitchOn();
            phone.GoToInternet();
            phone.SwitchOff();
        }
Exemplo n.º 10
0
        public override void RunApp()
        {
            IOutputWritter writter = new ConsoleWritter();
            writter.WriteLine("Run flyweight graphical redactor...");
            writter.WriteLine("Run abstract factory for creating primitives");

            PrimitiveFactory factory = new PrimitiveFactory();
            List<Primitive> primitives = new List<Primitive>()
            {
                factory.CreatePoint(10,20),
                factory.CreateRectangle(15,20),
                factory.CreateSquare(5),
                factory.CreateSquare(5),
                factory.CreateRectangle(100,100)
            };

            Image image = factory.CreateImage(primitives);
            DrawContext contextForDrawing = new DrawContext(640,480, "RED");
            image.DrawSelf(contextForDrawing);

            writter.WriteLine("... new context ...");
            image.DrawSelf(new DrawContext(1024,768, "BLUE"));
        }