......
public void actionPerformed(ActionEvent e)
{
if (e.getSource() == saleButton)
{
processSale(Wine wi);
//System.out.println("fvghj");
}
else if (e.getSource() == returnButton)
{
processReturn(Wine wi);
//System.out.println("fdgchj");
}
}
//create a wine object to be returned - responsible for getting details from textfields when either sale or return is pressed
//this object is then passed to the relevant method in LWMGUI to process either sale or return
public Wine getWine()
{
String wName = nameWineText.getText();
String costBottles = costBottleText.getText();
int cBottle = Integer.parseInt(costBottles);
//System.out.println(cBottle);
//get numBottle
String numBottles = numBottlesText.getText();
int nBottle = Integer.parseInt(numBottles);
//System.out.println(nBottle);
Wine wi = new Wine(wName, cBottle, nBottle);
return wi;
}
private int processSale(Wine wi)
{
int totalSaleAmount = wi.getNumBottle() * (int) wi.getCostBottle();
//System.out.println(totalAmount);
transactionText.setText("" + totalSaleAmount);
return totalSaleAmount;
}
private int processReturn(Wine wi)
{
int totalReturnAmount = wi.getNumBottle() * (int) wi.getCostBottle();
//System.out.println(totalReturnAmount);
transactionText.setText("" + totalReturnAmount);
return totalReturnAmount;
}
......I m having problems with an actionPerformed method. I have got text from user input textfields to give me the cost, quantity and name of a wine, for a sale or return to be processed. I have created a Wine object (wi) with this information, and want to pass it to further methods, whether sale or return.
I can t get the processSale() or processReturn() methods to work, and I m really confused!! I thought passing the Wine wi object to the methods would work? Here is the relevant code;