这个小方法是包含许多单独类的超大型程序的一部分。下面的方法用于调用我的Purchase类的一部分,该类跟踪购买了多少库存。但是,尽管我上面已实例化如下
Purchase currentPurchase;
我继续收到错误“期望标识符”和“找不到符号”。
方法:
public double processPurchase(currentPurchase){
lemonsBought = currentPurchase.getNumLemonsBought();
iceBought = currentPurchase.getNumLemonsBought();
cupsBought = currentPurchase.getNumCupsBought();
sugarBought = currentPurchase.getNumSugarBought();
lemonInventory += lemonsBought;
iceInventory += iceBought;
cupInventory += cupsBought;
sugarInventory += sugarBought;
money -= (.5 * lemonsBought) + (2 * iceBought) + (2 * cupsBought) + (0.25 * sugarBought);
return currentPurchase;
}
金钱是一个单独的预先实例化的变量
最佳答案
您需要将标识符添加到函数中,否则Java编译器将不知道该接收什么。
public double processPurchase(Purchase currentPurchase){