• Advertisement
Sign in to follow this  

problem with updating item count based on customer amount ordered.

This topic is 1899 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

so, uh sorry for once again bothering this great forum with my silly questions........but having a bit of an arithimetic problem....(seems easy in theory at least...). anyways, my problem is that i can't get the item to update properly once the customer orders the amount items: case in point:

(i can't paste a picture........I've lost the control panel on top.....anyways, i'll try my best to explain it.

private void purchase()
HardwareItem Item = null;
Customer customer = null;

Item = store.getStock().elementAt(this.itemSelection.getSelectedIndex() - 1);

if(Item != null)
for(int cust = 0; cust < custList.getLength(); cust++)
customer = custList.elementAt(cust);

String order = this.customerAmount.getText();

int amount = Integer.parseInt(order);

int itemAmount = Item.getNumOfPartsLeft();

int old = 0;
old = amount;
itemAmount -= old;

if(itemAmount <= 0)
itemAmount = 0;

if(itemAmount == 0)
JOptionPane.showMessageDialog(null, "the item with name: " + Item.getItemName() + " is out of stock");
this.partsL.setText(" " + Item.getNumOfPartsLeft());

ok, i can post links now....


that's one

now another:


hopefully this is better.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement