I m having trouble writing a method to calculate the total of some orders for a university project. Eclipse says there s an error, detailing only that the + is an invalid AssignmentOperator.
一些细节:
- There s no privacy issues.
- quantity is an int.
- getPrice() returns a double.
- total is a double
这种做法可能的确很简单,但因为如此,寻找答案非常困难。
public double calculateTotal(){
for(OrderItem currentItem:items){
for(int i=0;i<currentItem.quantity;i++){
total+currentItem.product.getPrice();
}
}
return total;
}