BookStore(final List<String> books) {
this.books = books;
}
public BookStore addBooks(List<String> additionalBooks) {
List<String> newBooks = getBooks();
newBooks.addAll(additionalBooks);
return new BookStore(newBooks);
}
public List<String> getBooks() {
List<String> copy = new ArrayList<>();
for (String book : books) {
copy.add(book);
}
return copy; <- Return deep copy, not the original
}
}