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 Walker { | |
walk(): void; | |
} | |
interface Swimmer { | |
swim(): void; | |
} | |
interface Flyer { | |
fly(): void; |
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 Animal { | |
fly(): void; | |
walk(): void; | |
swim(): void; | |
} | |
class Dog implements Animal { | |
public fly(): void { | |
// a dog can't fly |
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 Player { | |
public kickBallWithFeet(): void { | |
console.log("Kicking the ball with feet!") | |
} | |
} | |
class HandsUsingPlayer extends Player { | |
public holdBallWithHands(): void { | |
console.log("Holding the ball with hands!") |
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 Player { | |
public kickBallWithFeet(): void { | |
console.log("Kicking the ball with feet!") | |
} | |
public holdBallWithHands(): void { | |
console.log("Holding the ball with hands!") | |
} | |
} |
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 Player { | |
calculateGameRating(): number; | |
} | |
class Midfielder implements Player { | |
public assists: number; | |
public goals: number; | |
constructor(assists: number, goals: number) { |
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 Midfielder { | |
public assists: number; | |
public goals: number; | |
constructor(assists: number, goals: number) { | |
this.assists = assists; | |
this.goals = goals; | |
} | |
} |
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 Patient { | |
public firstName: string; | |
public lastName: string; | |
public email: string; | |
public age: number; | |
} | |
class ReportGenerator { | |
public saveToPdf(patient: Patient): void { | |
// here is code to generate PDF report for patient |
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 Patient { | |
public firstName: string; | |
public lastName: string; | |
public email: string; | |
public age: number; | |
public savePatientReport(): void { | |
// here is code to generate PDF report for patient | |
} | |
} |
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 IOcassion { | |
accept(singer: ISinger): void; | |
} | |
interface ISinger { | |
singChildrenSongs(ocassion: ChildBirthday): void; | |
singWeddingSongs(ocassion: Wedding): void; | |
singConcertSongs(ocassion: Concert): void; | |
} |
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
const applePie: ApplePie = new ApplePie(); | |
const pumpkinPie: PumpkinPie = new PumpkinPie(); | |
applePie.makeDough(); | |
applePie.addPieIngredient(); | |
applePie.bake(); | |
pumpkinPie.makeDough(); | |
pumpkinPie.addPieIngredient(); | |
pumpkinPie.bake(); |