|
copies.put(copyId, new BookCopy(copyId, item)); |
Issue: creating two BookCopy instances, each one adds itself to the LibraryItem copy list in its constructor.
Solution:
copies.put(copyId, copy); instead of copies.put(copyId, new BookCopy(copyId, item));
awesome-low-level-design/solutions/java/src/librarymanagementsystem/LibraryManagementSystem.java
Line 32 in 43017e5
Issue: creating two BookCopy instances, each one adds itself to the LibraryItem copy list in its constructor.
Solution:
copies.put(copyId, copy); instead of copies.put(copyId, new BookCopy(copyId, item));