Skip to content

Instantly share code, notes, and snippets.

@isaacbatst
Created June 7, 2023 19:03
Show Gist options
  • Save isaacbatst/7c166a026fa844b50af6b8e2f85bd01e to your computer and use it in GitHub Desktop.
Save isaacbatst/7c166a026fa844b50af6b8e2f85bd01e to your computer and use it in GitHub Desktop.
Aplicação Setinha
class Turma {
constructor(private inspiracao = 100){}
incrementInspiracao(valor: number){
this.inspiracao += valor
}
getInspiracao(){
return this.inspiracao
}
}
abstract class Character {
constructor(
private name: string,
){}
abstract special(): void
}
class Setinha extends Character {
constructor(private turma: Turma){
super('Setinha')
}
special(): void {
this.turma.incrementInspiracao(8000);
}
}
const turma27 = new Turma()
turma27.getInspiracao() // 100
const setinha = new Setinha(turma27)
setinha.special()
turma27.getInspiracao() // +8000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment