Skip to content

Instantly share code, notes, and snippets.

@carlosrojaso
Last active August 10, 2021 11:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carlosrojaso/3519bb367d94e4410bdd822b76295bea to your computer and use it in GitHub Desktop.
Save carlosrojaso/3519bb367d94e4410bdd822b76295bea to your computer and use it in GitHub Desktop.
class Soldier {
constructor(level) {
this.level = level;
}
attack() {
return this.level * 1;
}
}
class SuperSoldier {
constructor(level) {
this.level = level;
}
attackWithShield() {
return this.level * 10;
}
}
class SoldierAdapter {
constructor(superSoldier) {
this.superSoldier = superSoldier;
}
attack() {
return this.superSoldier.attackWithShield();
}
}
export { Soldier, SuperSoldier, SoldierAdapter };
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment