Advertisement
Guest User

Untitled

a guest
Nov 16th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. /**
  2. * Removes a book by title.
  3. */
  4. public void remove(String bookTitle) {
  5. for(int i = 0; books.length < i; i++){
  6. if(books[i].getTitle().equals(bookTitle)){
  7. books[i] = null;
  8. }
  9. else
  10. {
  11. System.out.println("");
  12. }
  13. }
  14. }
  15.  
  16. /**
  17. * Adds a new book.
  18. */
  19. public void add(Book book) {
  20.  
  21. if(book != null && books.length < 100){
  22. int i = 11;
  23. books[i] = book;
  24. i++;
  25. }
  26. else{
  27. System.out.println("Book Storage is Full.");
  28. }
  29.  
  30. }
  31.  
  32. /**
  33. * Gets a book by title.
  34. */
  35. public Book getByTitle(String title) {
  36. for(int k = 0; books.length < 100; k++){
  37. if(books[k].getTitle().equals(title)){
  38. return books[k];
  39. }
  40. else{
  41. return null;
  42. }
  43.  
  44. }
  45. return null;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement