Why doesn't this run? The superclass and other classes should be ok.
Are there any obvious mistakes?
When I create the object and when I click void main(string []args)
, BlueJ says ''method call'' empty parameter field
in a new window.
Please help, here is the code:
import java.util.*;
public class libraryManager {
public void main (String [] args) {
String input =" ";
ArrayList<Book> books = new ArrayList<Book>();
ArrayList<CD> cds = new ArrayList<CD>();
Book book1 = new Book();
CD cd1 = new CD();
System.out.println("Welcome to library management system");
Scanner reader = new Scanner(System.in);
do{
System.out.println("Main menu: ");
System.out.println(" 1. Add book to the library ");
System.out.println(" 2. Add CD to the library ");
System.out.println(" 3. Print items ");
System.out.println(" 4. Exit ");
input = reader.nextLine();
if (input.equals("1")){
System.out.println("Input new book: ");
input = reader.nextLine();
book1.setName(input);
books.add(book1); input ="1";
}
if (input.equals("2")){
System.out.println("Input new CD: ");
input = reader.nextLine();
cd1.setName(input);
cds.add(cd1);}
if (input.equals("3")){
System.out.println("Library contains:");
for (int i= 0; i<books.size(); i++){
System.out.println("Book: " + books.get(i).getName());
}
for (int i = 0; i<cds.size(); i++){
System.out.println("CD: " +cds.get(i).getName());
}
break;
}
}while(!input.equals( "4"));
}
}
This
is incorrect. It needs to be
static
likeother valid choices (from Wikipedia) are
or