Created
June 7, 2023 19:03
-
-
Save isaacbatst/7c166a026fa844b50af6b8e2f85bd01e to your computer and use it in GitHub Desktop.
Aplicação Setinha
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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