コード例 #1
0
        /// <summary>
        /// Прокси
        /// </summary>
        public static void GoProxyStock()
        {
            Serviceman     serviceman    = new ExperiencedOfficer();
            IMilitaryStock militaryStock = new ProxyStock(serviceman, 100, 20, 15);

            Print(militaryStock.TakeArmor(80));
            Print(militaryStock.TakeArmor(10));
            Print(militaryStock.TakeArmor(20));
            Print(militaryStock.TakeFood(30));
            Print(militaryStock.TakeFood(10));
            Print(militaryStock.TakeWeapon(5));
            Print(militaryStock.TakeWeapon(20));
            Console.ReadKey();
        }
コード例 #2
0
ファイル: Example.cs プロジェクト: Konversys/PLArmy
        /// <summary>
        /// Делегирование
        /// </summary>
        public static void GoDelegateServiceman()
        {
            Serviceman serviceman;

            serviceman = new Conscript();
            serviceman.CanICommand();
            Console.WriteLine();
            serviceman.CanIEquipment();
            Console.WriteLine();
            serviceman = new ExperiencedOfficer();
            serviceman.CanICommand();
            Console.WriteLine();
            serviceman.CanIEquipment();
            Console.WriteLine();
            serviceman = new ContractTechnician();
            serviceman.CanICommand();
            Console.WriteLine();
            serviceman.CanIEquipment();
            Console.ReadKey();
        }