Last active
March 13, 2019 13:33
-
-
Save Morzanne/0b3d2452314486506be5d2530a4ff6f0 to your computer and use it in GitHub Desktop.
Typescript noe.ts
This file contains 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
interface pattesnoires { | |
nbPattes?: number; | |
color?: string; | |
} | |
class Animal implements pattesnoires{ | |
nbPattes?: number; | |
color? : string; | |
cri?: string; | |
capacite?:string; | |
constructor(nbPatte:number, capacite:string){ | |
this.nbPattes=nbPatte; | |
this.capacite = capacite; | |
} | |
photographier(){ | |
console.log("Je peux prendre tous les animaux en photo"); | |
} | |
} | |
class Chien extends Animal{ | |
cri : string; | |
color : string; | |
constructor(nbPattes:number, color : string, cri:string, capacite:string){ | |
super(nbPattes, capacite); | |
this.cri = cri; | |
this.color = color; | |
} | |
aboyer(){ | |
console.log("Tous ces toutous ont vraiment la capacité d' "+this.cri+" tellement fort !") | |
} | |
} | |
class Chat extends Chien{ | |
constructor(nbPattes:number, color: string, cri: string, capacite:string){ | |
super(nbPattes,color, cri, capacite); | |
} | |
miauler(){ | |
console.log("Tous les chats du quartier n'arretent pas de "+this.cri+" c'est insupportable") | |
} | |
} | |
class fish extends Animal{ | |
capacite : string; | |
constructor(nbPattes : number , capacite:string){ | |
super(nbPattes, capacite); | |
this.capacite=capacite; | |
} | |
nager(){ | |
console.log("Tous ces poissons peuvent "+this.capacite+" si vite !") | |
} | |
} | |
class piaf extends Animal{ | |
color : string; | |
constructor(nbPattes:number, capacite:string, color:string){ | |
super(nbPattes, capacite) | |
this.color = color; | |
} | |
voler(){ | |
console.log("Ecoute moi bien le piaf, toi et tes copains pourriez arreter de "+this.capacite+" ? C'est genant a la fin !") | |
} | |
} | |
let requin = new fish(0, 'nager'); | |
let pets = new Animal(4,"jouer"); | |
let chartreux = new Chat(4, "noir", "miaouuuuuu","chasser"); | |
let MoonMoon = new Chien(4, "noir", "aboyer","rapporter la balle"); | |
let Mesange = new piaf(2, "voler", "white"); | |
pets.photographier(); | |
chartreux.miauler(); | |
MoonMoon.aboyer(); | |
Mesange.voler(); | |
requin.nager(); | |
function feed(nourrir : pattesnoires){ | |
if (nourrir.color=="noir"){ | |
console.log("Tiens animal alimentant le folklor, avales !") | |
}else{ | |
return; | |
} | |
} | |
function carresser(carresse : pattesnoires){ | |
if (carresse.nbPattes==4){ | |
console.log("Tiens sombre quadrupède, je te fais l'honneur d'un geste affectif") | |
}else{ | |
return; | |
} | |
} | |
let terreNeuve= new Chien(4, "noir", "aboie","rapporter la balle"); | |
let europeen = new Chat(4,"noir", "miauler", "chasser"); | |
feed(europeen); | |
carresser(terreNeuve); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment