Advertisement
ItaiMaman

Public Class BookStore

Mar 30th, 2020
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. public class BookStore {
  2.  
  3. public static void main(String[] args) {
  4.  
  5. int count = 0;
  6. Book[] books = new Book[3];
  7.  
  8. books[0] = new Book("Hunger Games", "Charles blue", 2016, 60.5);
  9. books[1] = new Book("The Hobbit", "Michael Lies", 2012, 35.0);
  10. books[2] = new Book("Harry potter", "J.K. Rowling", 2019, 85.0);
  11.  
  12. books[0].updatePrice(20);
  13. books[1].updatePrice(-10);
  14. books[2].updatePrice(-40);
  15.  
  16. System.out.println("Updated prices:");
  17.  
  18. for (int i = 0; i < 3; i++) {
  19. System.out.println(books[i].name + ": " + books[i].price + " ₪");
  20.  
  21. if(books[i].isNew(2020)) count++;
  22. }
  23. System.out.println(count + " books are new(were released in the last three years)");
  24.  
  25. }
  26.  
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement