public static IWeaponBehaviour CreateWeapon(string name)
        {
            IWeaponBehaviour newWeapon;

            switch (name)
            {
            case "Sword":
                newWeapon = new Sword();
                break;

            case "Bow":
                newWeapon = new Bow();
                break;

            case "Dagger":
                newWeapon = new Dagger();
                break;

            default:
                newWeapon = null;
                break;
            }
            return(newWeapon);
        }
コード例 #2
0
 public Knight(string name) : base(name)
 {
     Weapon = new Dagger();
 }