-
February 1st, 2019, 09:54 PM
#1
Does any one can Help improve the methods above
i was told to make an Books Library . i end up with that Code lines . i hope some one could help me to make it better then it is right now , this is mine Code lines of 2 method that i need to improve :
Code:
HashMap<Long,Book> books = new HashMap<>();
@Override
public BooksReturnCode addBookItem(Book book) {
if(book.getPickPeriod()<3)
return BooksReturnCode.PICK_PERIOD_LESS_MIN;
if(book.getPickPeriod()>30)
return BooksReturnCode.PICK_PERIOD_GREATER_MAX;
return books.putIfAbsent(book.getIsbn(), book)==null?
BooksReturnCode.OK:BooksReturnCode.BOOK_ITEM_EXIST;
}
@Override
public BooksReturnCode addBookExemplars(long isbn, int amount) {
if(books.containsKey(isbn)) {
amount++;
return BooksReturnCode.OK;
}
return BooksReturnCode.NO_BOOK_ITEM;
}
-
February 2nd, 2019, 06:43 AM
#2
Re: Does any one can Help improve the methods above
Does the code compile without errors?
Does the code do what is expected when it executes?
Norm
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|