import javax.swing.JOptionPane;
public class BookApp{
//presence of main class indicates strating point, or
//beginning java program that will create and use objects
public static void main(String args[]){
String choice = "";
//Continuously loop to listen for user input
while (!(choice.equalsIgnoreCase ("x"))){
String code = JOptionPane.showInputDialog(
"Enter A Book Code:");
String name = JOptionPane.showInputDialog(
"Or Enter A Book Name:");
//Instantiate or create a new Book object from the Book
//class called mybook
Book mybook;
if (name != null)
{
System.out.println("name" + name);
mybook = new Book(code, name);
}
else
{
System.out.println("code" + code);
mybook = new Book(code);
}
String message = "You have selected:\n"
+ " Title:" + mybook.getTitle() + "\n"
+ " Price:" + mybook.getPrice() + "\n"
+ "Press Enter to continue or x for exit.";
choice = JOptionPane.showInputDialog(null, message, "Book",
JOptionPane.PLAIN_MESSAGE);
}//end while
System.exit(0);
}
}