Created
March 20, 2019 15:21
-
-
Save mehdihettak/28a4d5bc7c655f112cf164501933d5e1 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
| interface FourLegs { | |
| readonly fourLeg: true; | |
| } | |
| interface Black { | |
| readonly black: true; | |
| } | |
| class Animal { | |
| } | |
| class Cat extends Animal implements FourLegs { | |
| fourLeg; | |
| } | |
| class EuropeanCat extends Cat implements Black { | |
| black; | |
| } | |
| class ChartreuxCat extends Cat { | |
| } | |
| class Dog extends Animal implements FourLegs { | |
| fourLeg; | |
| } | |
| class DogNewfoundland extends Dog implements Black{ | |
| black; | |
| } | |
| class DogMoonMoon extends Dog { | |
| } | |
| class Bird extends Animal { | |
| } | |
| class Chickadee extends Bird { | |
| } | |
| class Blackbird extends Bird implements Black{ | |
| black; | |
| } | |
| class Fish extends Animal { | |
| } | |
| class Tuna extends Fish { | |
| } | |
| class Shark extends Fish { | |
| } | |
| class Worm extends Animal { | |
| } | |
| function shoot(animal: Animal) { | |
| console.log('Une magnifique photo d\'un animal'); | |
| } | |
| function meow(cat: Cat) { | |
| console.log('Lorsque je veux quelque chose je miaule car je suis un chat'); | |
| } | |
| function woof(dog: Dog) { | |
| console.log('J\'aboie pour signaler un danger car je suis un chien'); | |
| } | |
| function fly(bird: Bird) { | |
| console.log('Je vole car je suis oiseau'); | |
| } | |
| function swim(fish: Fish) { | |
| console.log('Je nage car je suis un poisson'); | |
| } | |
| function caress(fourLeg: FourLegs) { | |
| console.log("J'ai 4 pattes"); | |
| } | |
| function feed(black: Black) { | |
| console.log("Je suis de couleur noire"); | |
| } | |
| //Quelques vérification | |
| console.log('Animal :'); | |
| var animal = new Animal; | |
| shoot(animal); | |
| console.log(); | |
| console.log('Chat :'); | |
| var cat = new Cat; | |
| shoot(cat); | |
| meow(cat); | |
| caress(cat); | |
| console.log(); | |
| console.log('Chat de race européen :'); | |
| var euCat = new EuropeanCat; | |
| shoot(euCat); | |
| meow(euCat); | |
| caress(euCat); | |
| feed(euCat); | |
| console.log(); | |
| console.log('Chat de race chartreux :'); | |
| var chartreuxCat = new ChartreuxCat; | |
| shoot(chartreuxCat); | |
| meow(chartreuxCat); | |
| caress(chartreuxCat); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment