diff --git a/Book.java b/Book.java index 4173a3e..a74a21b 100644 --- a/Book.java +++ b/Book.java @@ -1,6 +1,6 @@ /* * Written by : Bin Hong Lee - * Last edited : 4/27/2016 + * Last edited : 5/31/2016 */ class Book @@ -85,6 +85,11 @@ class Book double fine; boolean monChange = false; + if(currentDay[0] < dueDate[0] || (currentDay[0] == dueDate[0] && currentDay[1] < dueDate[1]) || (currentDay[0] == dueDate[0] && currentDay[1] == dueDate[1] && currentDay[2] <= dueDate[2])) + { + return 0; + } + while(currentDay[0] > dueDate[0]) { currentDay[0]--; diff --git a/BookFactory.java b/BookFactory.java index 804630a..16a9cdb 100644 --- a/BookFactory.java +++ b/BookFactory.java @@ -1,6 +1,6 @@ /* * Written by : Bin Hong Lee - * Last edited : 4/27/2016 + * Last edited : 5/31/2016 */ import java.util.*; @@ -15,16 +15,6 @@ class BookFactory id = 0; } - public Book newBook() - { - Book temp = new Book(id); - books.add(temp); - - id++; - - return temp; - } - public Book newBook(String title) { Book temp = new Book(title, id); @@ -37,7 +27,14 @@ class BookFactory public Book getBook(int index) { - return books.get(index); + try + { + return books.get(index); + } + catch (Exception e) + { + throw new NullPointerException(); + } } public Book getBook(String title) @@ -52,8 +49,6 @@ class BookFactory } } - System.out.println("Error 404 : Book not found"); - - return newBook(); + throw new NullPointerException(); } } diff --git a/Main.java b/Main.java index 4297eb0..c99d7f5 100644 --- a/Main.java +++ b/Main.java @@ -1,10 +1,11 @@ /* * Written by : Bin Hong Lee - * Last edited : 4/27/2016 + * Last edited : 5/31/2016 */ class Main { + Exception BookNotFound = new Exception("Error 404 : Book not found"); static BookFactory books = new BookFactory(); public static void main(String[] args) @@ -12,8 +13,4 @@ class Main } - public static void newBook() - { - books.newBook(); - } }