Created
May 31, 2024 05:44
-
-
Save amitasaurus/b83990c22bfd7732dc8799c0f14dc6fb to your computer and use it in GitHub Desktop.
Interfaces and Classes
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
// Write an interface here | |
interface Directory { | |
addFile: (name: string) => void; | |
} | |
class DesktopDirectory implements Directory { | |
addFile(name: string) { | |
console.log(`Adding file: ${name}`); | |
} | |
showPreview(name: string) { | |
console.log(`Opening preview of file: ${name}`); | |
} | |
} | |
const Desktop = new DesktopDirectory(); | |
Desktop.addFile("lesson-notes.txt"); | |
Desktop.showPreview("lesson-notes.txt"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment