Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. // This is the Soldier API
  2. class Soldier {
  3. equipShootingGun(shootingGun) {
  4. this.shootingGun = shootingGun;
  5. }
  6. equipWhiteGun(whiteGun) {
  7. this.whiteGun = whiteGun;
  8. }
  9. stab(target) {
  10. // This doesn't look quite right
  11. shootingWeapon.shoot(target);
  12. }
  13. }
  14.  
  15. // ...
  16.  
  17. // This is the Soldier client
  18. const mary = new Soldier();
  19. mary.equipShootingGun(new handGun());
  20. mary.equipWhiteGun(new Knife());
  21. mary.stab(new Soldier()); // Shootin... wait!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement