Hi i am doing a coll assignment over Christmas on objects and classes. Its to make a library system that allows users to add books etc.Im having a problem printing the addresses and adding books. Ill show my code to help ye get a better idea. This is my main class.
public static void main(String[] args) {
Library firstLibrary = new Library ("Moylish Park, Limerick");
Library secondLibrary = new Library ("Clare Street, Limerick");
Library thirdLibrary = new Library ("Nenah road, Thurles");
firstLibrary.addBook(new Book("Java how to program"));
firstLibrary.addBook(new Book("What's new in Java 7?"));
firstLibrary.addBook(new Book("Java in a nutshell"));
firstLibrary.addBook(new Book("Pro android 2"));
secondLibrary.addBook(new Book("The Power of colour"));
secondLibrary.addBook(new Book("The Genius of Being"));
secondLibrary.addBook(new Book("Creativity in Nature"));
System.out.println("Library hours:");
System.out.println("");
System.out.println("Library Addresses:");
firstLibrary.printAddress();
secondLibrary.printAddress();
thirdLibrary.printAddress();
}
}
// Book example = new Book ("Java how to program");
// System.out.println("Title (should be Java How To Program): " + example.getTitle());
//
// System.out.println("Borrowed? (Should be false) " + example.isBorrowed());
// example.borrowed();
//
// System.out.println("Borrowed? (should be true): " + example.isBorrowed());
// example.rented();
//
// System.out.println("Borrowed? (should be false): " + example.isBorrowed());
// }
//}
This is my library class
public class Library {
String address;
Library (String address){
this.address = address;
}
public void printOpeningHours(){
System.out.println("Librarys are open daily from 9am to 5pm");
}
public void printAddress() {
System.out.println(this.address);
}
void addBook(Book book) {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
}
I also have a book class but i dont think thats needed for this problem im stuck on. the add book method was added for me by netbeans can someone explain why? Also why do the addresses not print and how do i add books? Im not looking for ye to do my assignment i actually want to learn and understand. Thanks in advance!