예제 #1
0
 public static void Main()
 {
     //create a weapon object andd
     Weapon myWeapon = new Weapon();
     // create a myWarrior variable and initialize it as Warrior
     var myWarrior = new Warrior();
     // assign myWeapon value to the myWarrior with the setter method.
     myWarrior.setWeapon(myWeapon);
     myWarrior.Attack("lame programmers");
 }
예제 #2
0
 /** setWeapon is a setter method responsible for setting the Weapons obj
 * @param myWeapon the weapon to be used
 */
 public void setWeapon(Weapon myWeapon)
 {
     this.myWeapon = myWeapon;
 }