Kimes

Untitled

Mar 29th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.44 KB | None | 0 0
  1. public void addBook(Book newAddbook) {
  2.             if (bookMap.values().isEmpty()) {
  3.                 Integer id = uniqueID++;
  4.                 newAddbook.setId(id);
  5.                 bookMap.put(id, newAddbook);
  6.                 return;
  7.             }
  8.             for (Book book : bookMap.values()){
  9.                 if (book.equals(newAddbook)) {
  10.                     book.addCopy();
  11.                     return;
  12.                 } else {
  13.                     Integer id = uniqueID++;
  14.                     newAddbook.setId(id);;
  15.                     bookMap.put(id, newAddbook);
  16.                     return;
  17.                 }
  18.                
  19.             }
  20.     }
Advertisement
Add Comment
Please, Sign In to add comment