Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.67 KB | None | 0 0
  1.     interface WeaponBehaviour {
  2.         void UseWeapon();
  3.     }
  4.  
  5.     class KnifeBehaviour : WeaponBehaviour {
  6.         public void UseWeapon() {
  7.             // implements stabbing with knife
  8.         }
  9.     }
  10.  
  11.     class AxeBehaviour : WeaponBehaviour {
  12.         public void UseWeapon() {
  13.             // implemenets chopping with axe
  14.         }
  15.     }
  16.  
  17.     // etc.
  18.  
  19.     abstract class Character {
  20.         WeaponBehaviour weapon;
  21.         void Fight() {
  22.             weapon.UseWeapon();
  23.         }
  24.  
  25.         void SetWeapon(WeaponBehaviour weapon) {
  26.             this.weapon = weapon;
  27.         }
  28.     }
  29.  
  30.     class Player : Character {
  31.         // implement player class
  32.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement