Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Soldier {
- handEquip(weapon) {
- this.equipedWeapon = weapon;
- }
- useHandEquipmentAgainst(enemy) {
- this.equipedWeapon.shoot(enemy);
- }
- }
- class MachineGun {
- open(bottle) {
- alert('*Opening A Bottle With The Machine Gun*');
- }
- shoot(enemy) {
- alert('*Shooting The Machine Gun Against The Enemy*');
- }
- }
- // ...
- const john = new Soldier();
- john.handEquip(new MachineGun());
- john.useHandEquipmentAgainst(new Soldier());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement