Guest User

Untitled

a guest
Jul 17th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. public class BookUtils {
  2.  
  3. public static boolean containsBook(Book[] books, Book book) {
  4.  
  5. boolean bool=false;
  6.  
  7.  
  8.  
  9. for(int i=0;i<books.length;i++){
  10.  
  11. if(books[i].isbn==book.isbn && books[i]!=null){
  12.  
  13. bool=true;
  14.  
  15. }
  16.  
  17. }
  18.  
  19. return bool;
  20.  
  21. }
  22.  
  23.  
  24. public static void addBook(Book[] books, Book book) {
  25.  
  26. for(int i=0;i<books.length;i++){
  27.  
  28. if(books[i]==null && book==null){
  29.  
  30. books[books.length]=book;
  31.  
  32. }
  33.  
  34. }
  35.  
  36.  
  37.  
  38. }
  39.  
  40.  
  41. public static Book getCheapestBook(Book[] books) {
  42.  
  43. double minimum=books[0].price;
  44.  
  45. Book cheapest=new Book();
  46.  
  47. for(int i=0;i<books.length;i++){
  48.  
  49. if(books[i].price<minimum){
  50.  
  51. minimum=books[i].price;
  52.  
  53. cheapest=books[i];
  54.  
  55.  
  56.  
  57. }
  58.  
  59. }
  60.  
  61.  
  62. return cheapest;
  63.  
  64. }
  65.  
  66. }
Add Comment
Please, Sign In to add comment