Jump to content

View more

Image of the Day

The night is still, but the invasion brings chaos. #screenshotsaturday #hanako #indiegame #gameart #ue4 #samurai https://t.co/cgILXuokoS
IOTD | Top Screenshots

The latest, straight to your Inbox.

Subscribe to GameDev.net Direct to receive the latest updates and exclusive content.


Sign up now

problem with updating item count based on customer amount ordered.

4: Adsense

Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.


  • You cannot reply to this topic
1 reply to this topic

#1 Enerjak   Members   

277
Like
0Likes
Like

Posted 08 November 2012 - 02:40 PM

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;
    amount++;
    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");
	 }
    }
    customer.setOrdered(amount);
    Item.setNumOfPartsLeft(itemAmount);
    this.partsL.setText(" " + Item.getNumOfPartsLeft());
   }
  }
}

ok, i can post links now....

http://puu.sh/1nWw0

that's one

now another:

http://puu.sh/1nWwT

hopefully this is better.

#2 Enerjak   Members   

277
Like
0Likes
Like

Posted 08 November 2012 - 06:53 PM

please ignore this thread.........




Old topic!

Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.