Last active
August 29, 2015 14:08
-
-
Save JorgeCastilloPrz/1f242d36cbbec66ac72f 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
public void BookController { | |
private static BookController instance = null; | |
private BookRepository bookRepository = new PersistentBookRepository(); | |
protected BookController() {} | |
public static BookController getInstance() { | |
if(instance == null) { | |
instance = new BookController(); | |
} | |
return instance; | |
} | |
public List<BookPreview> getAllBookPreviews() { | |
List<Book> allBooks = bookRepository.getAllBooks(); | |
List<BookPreview> bookPreviews = new LinkedList<BookPreview>(); | |
for (Book currentBook : allBooks) { | |
bookPreviews.add(getBookPreview(currentBook)); | |
} | |
return bookPreviews; | |
} | |
public BookPreview getBookPreview(Book book) { | |
return new BookPreview(book.getCover, book.getPrologue, book.getChapterByNumber(1)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment