Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class BookStore {
- public static void main(String[] args) {
- int count = 0;
- Book[] books = new Book[3];
- books[0] = new Book("Hunger Games", "Charles blue", 2016, 60.5);
- books[1] = new Book("The Hobbit", "Michael Lies", 2012, 35.0);
- books[2] = new Book("Harry potter", "J.K. Rowling", 2019, 85.0);
- books[0].updatePrice(20);
- books[1].updatePrice(-10);
- books[2].updatePrice(-40);
- System.out.println("Updated prices:");
- for (int i = 0; i < 3; i++) {
- System.out.println(books[i].name + ": " + books[i].price + " ₪");
- if(books[i].isNew(2020)) count++;
- }
- System.out.println(count + " books are new(were released in the last three years)");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement