Skip to content

Instantly share code, notes, and snippets.

@amitasaurus
Created May 31, 2024 05:44
Show Gist options
  • Save amitasaurus/b83990c22bfd7732dc8799c0f14dc6fb to your computer and use it in GitHub Desktop.
Save amitasaurus/b83990c22bfd7732dc8799c0f14dc6fb to your computer and use it in GitHub Desktop.
Interfaces and Classes
// 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