Well that didn't exactly solve the problem but it continued without crashing! lol
I got the program to display the number of objects created from within the loop but any time I want to try and show it outside the loop it never works. Here is the modified driver class:
That last line doesn't work but it don't cause the program to crash either! lol It's a start. I just don't understand why it doesn't work outside the loop... And btw thx for all your help.Code:public static void main(String[] args){ String choice = ""; try{ while (!(choice.equalsIgnoreCase("x"))){ String title = JOptionPane.showInputDialog( "Enter a book code:"); String inputQuantity = JOptionPane.showInputDialog( "Enter a quantity:"); int quantity = parseQuantity(inputQuantity); BookOrder bookOrder = new BookOrder(title, quantity); String message = bookOrder.toString() + "\n" + "Instances created: " + bookOrder.getObjectCount() + "\n" + "Press Enter to continue or enter 'x' to exit:"; choice = JOptionPane.showInputDialog(null, message, "Book Order", JOptionPane.PLAIN_MESSAGE); }//end while } catch(NullPointerException e){ System.exit(0); } System.exit(0); System.out.println("Objects created: " + BookOrder.getObjectCount()); }
You'll have to pardon the odd placement of the code as I did this in Visual Studio.NET.




Reply With Quote