コード例 #1
0
        public void SimulateDropAndPickupByOtherHero()
        {
            IHero swordsmanOne = HeroFactory.CreateSwordsman();
            IHero swordsmanTwo = HeroFactory.CreateSwordsman();

            IHeroWeapon w = swordsmanOne.DropWeapon();
            IHeroWeapon _ = swordsmanTwo.DropWeapon();


            swordsmanTwo.PickUpWeapon(w);

            Console.WriteLine($"'{swordsmanTwo.Name}' je pokupio oružje '{w.Name}'");
        }
コード例 #2
0
        public void SimulateWeaponDropAndPickup()
        {
            IHero wizard    = HeroFactory.CreateWizard();
            IHero swordsman = HeroFactory.CreateSwordsman();

            IHeroWeapon magic = wizard.DropWeapon();
            IHeroWeapon _     = wizard.DropWeapon();

            swordsman.PickUpWeapon(new Spear(15));

            try
            {
                swordsman.PickUpWeapon(magic);
            }
            catch (BackpackFullException e)
            {
                Console.WriteLine(e.Message);
            }
            catch (IllegalWeaponException e)
            {
                Console.WriteLine(e.Message);
            }
        }