Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This is the Soldier API
- class Soldier {
- equipShootingGun(shootingGun) {
- this.shootingGun = shootingGun;
- }
- equipWhiteGun(whiteGun) {
- this.whiteGun = whiteGun;
- }
- stab(target) {
- // This doesn't look quite right
- shootingWeapon.shoot(target);
- }
- }
- // ...
- // This is the Soldier client
- const mary = new Soldier();
- mary.equipShootingGun(new handGun());
- mary.equipWhiteGun(new Knife());
- mary.stab(new Soldier()); // Shootin... wait!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement