Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- interface WeaponBehaviour {
- void UseWeapon();
- }
- class KnifeBehaviour : WeaponBehaviour {
- public void UseWeapon() {
- // implements stabbing with knife
- }
- }
- class AxeBehaviour : WeaponBehaviour {
- public void UseWeapon() {
- // implemenets chopping with axe
- }
- }
- // etc.
- abstract class Character {
- WeaponBehaviour weapon;
- void Fight() {
- weapon.UseWeapon();
- }
- void SetWeapon(WeaponBehaviour weapon) {
- this.weapon = weapon;
- }
- }
- class Player : Character {
- // implement player class
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement