Esempio n. 1
0
        static void ExplictInterfaceTest()
        {
            var        item      = new WarmKiller();
            IKiller    killer    = item;
            IGentleman gentleman = item;

            killer.Kill();
            gentleman.Love();
        }
Esempio n. 2
0
        static void Main()
        {
            //way1:
            var wk = new WarmKiller();

            wk.Love();
            IKiller killer = wk;

            killer.Kill();

            // way2:
            //IKiller killer = new WarmKiller();
            //killer.Kill();
            //var wk = (IGentlemen)killer;
            //wk.Love();
        }
Esempio n. 3
0
        // Many pieces, which focus around the soldier.
        // Using them is a problem because each time,
        // they need to be rewired, restructured and it's not known
        public void PlayWar()
        {
            var shooter = new Soldier();
            var target  = new Soldier();

            // Shot should determine if damage is taken or not
            shooter.Shoot(target);
            _damager.Damage(target);
            // Soldier can move by itself
            _mover.Move(shooter, new Vector3D());


            if (target.Hp <= 0)
            {
                // Soldier should know how it dies
                _killer.Kill(target);
            }
            else
            {
                // Soldiers know how to give first aid
                _healer.Heal(target);
            }
        }