我的支付类只有一个本地私有变量——totalCost,因此totalCost 也有一个getter 和setter 方法。TotalCost 是唯一的局部变量,因为它是唯一用于支付类中多个方法的变量。这个类应该有更多的getter和setter吗?
public class Payment {
private int totalCost;
public Payment(){
}
public int calculateItemcost(int itemQuantity, int itemPrice){
return itemPrice * itemQuantity;
public int calculateTotalcost(int itemCost){
return totalCost = totalCost + itemCost;
}
public int calculateBalance(int clickedValue, int totalCost){
return this.totalCost = totalCost - clickedValue;
public int getTotalcost(){
return this.totalCost;
}
public void setTotalcost(int totalcost) {
this.totalCost = totalcost;
}
}