Last active
March 20, 2025 23:59
-
-
Save trikitrok/6f408abd9b10c99d547a817253089bfc 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
// After steps 1 and 2 | |
class Library { | |
private readonly display: Display; | |
constructor(display: Display) { | |
this.display = display; | |
} | |
printBooks(books: Book[], inputReader: AcmeInputReader): void { | |
const libraryData = new LibraryData(inputReader); // <- new wrapper | |
const libraryName = this.getLibraryName(inputReader); // <- new method | |
this.display.show(libraryName); | |
for (const book of books) { | |
this.display.show(book.getName()); | |
} | |
} | |
private getLibraryName(inputReader: AcmeInputReader): string | |
{ | |
return inputReader.readLine(); | |
} | |
} | |
// wrapper | |
class LibraryData | |
{ | |
private readonly inputReader: AcmeInputReader; | |
constructor(inputReader: AcmeInputReader) | |
{ | |
this.inputReader = inputReader; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment