Created
December 8, 2016 21:05
-
-
Save moonpyk/b1bdfcbc4799dd69d11c45e713d33c80 to your computer and use it in GitHub Desktop.
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
| abstract class CasClinique { | |
| hasFievre(): boolean { | |
| return true; | |
| } | |
| symptomes(): string[] { | |
| return null; | |
| } | |
| hasSymptome(s: string) { | |
| var ss = this.symptomes(); | |
| if (ss == null) { | |
| return false; | |
| } | |
| return ss.indexOf(s) > 0; | |
| } | |
| } | |
| class Bronchite extends CasClinique { | |
| symptomes(): string[] { | |
| return ["toux"] | |
| } | |
| } | |
| class DepressionNerveuse extends CasClinique { | |
| hasFievre():boolean { | |
| return false; | |
| } | |
| symptomes():string[] { | |
| return ["tristesse"] | |
| } | |
| } | |
| class Patient { | |
| private _maladie: CasClinique; | |
| constructor(m: CasClinique) { | |
| this._maladie = m; | |
| } | |
| examineCerveau() { | |
| if (this._maladie.hasSymptome("tristesse")) { | |
| console.log("ça sent la dépression") | |
| } | |
| } | |
| examinePoumons() { | |
| if (this._maladie.hasFievre() && this._maladie.hasSymptome("toux") ) { | |
| console.log("Patient tousse") | |
| } | |
| } | |
| examineTroudbal() { | |
| if (this._maladie.hasSymptome("malaucul") ) { | |
| console.log("Malocul") | |
| } | |
| } | |
| } | |
| var bebert = new Patient(new Bronchite()) | |
| bebert.examinePoumons(); | |
| bebert.examineTroudbal(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment