Ok guys, i've got some new code ready for ya...
Code:
java.lang.NullPointerException
at restaurant1model.ProductCatalog.getSpecification(ProductCatalog.java:36)
at restaurant1model.Register.enterItem(Register.java:54)
at restaurant1view.Program1.main(Program1.java:54)
Code:
public ProductSpecification getSpecification(String itemCode)
{
ProductSpecification item = null;
boolean foundFlag = false;
//System.out.println(itemCode);
for (int i = 0; i < productSpecifications.length && !foundFlag; i++) //for (int i = 0;!(i >= productSpecifications.length || foundFlag); i++)
{
if (itemCode.equals(productSpecifications[i].getItemId()))
{
item = productSpecifications[i];
foundFlag = true;
}
}
return item;
}
Code:
public boolean enterItem(String upc, int quantity)
{
boolean flag = false;
if (sale == null || sale.isComplete())
{
sale = new Sale();
}
ProductSpecification productionSpecification;
productionSpecification =
(ProductSpecification) productCatalog.getSpecification(upc);
if (productionSpecification != null)
{
flag = sale.makeLineItem(productionSpecification, quantity);
}
else
{
flag = false;
}
return flag;
}
Code:
case 1 : // Event 1 - Enter Item
{
boolean doSaleAgain;
do
{
int tableNumber = Program1.readInt("Enter Table Number");
String itemCode = JOptionPane.showInputDialog("Enter Item Code", "X00");
int quantity = Program1.readInt("Enter Quantity");
register.enterItem(itemCode, quantity);
doSaleAgain =
readBoolean("Do you wish to enter another item?");
}
while (doSaleAgain);
doAgain = true;
break;
}
The bottom three snippets are all assosciated with their respective parts of the original error message (top). Let me know what you want to know and I will do my best to answer.
Thank you all very much!!
-BoltedDown