ここで誰かの助けに感謝します。以下は、すべてのセッターとゲッターを含むクラスです。メイン クラスでは 3 つの顧客を作成し、値パラメーターでは 3 つの異なる番号を持っています。私がする必要があるのは、これらすべての値の合計値を見つけることです。各顧客値パラメーターの合計を計算して追加するメソッド (以下の bookingValue を参照) を作成する方法はありますか? 3 は固定数ではないことに注意してください。したがって、さらに顧客を追加することを選択した場合でも、メソッドが影響を受けることはありません。これはおそらく本当に基本的なことですが、誰かが私を正しい道に導くことができれば、それは素晴らしいことです、乾杯
public class Customer
{
private int identity;
private String name;
private String address;
private double value;
public Customer()
{
identity = 0;
name = "";
address = "";
value = 0.0;
}
public void setIdentity(int identityParam)
{
identity = identityParam;
}
public int getIdentity()
{
return identity;
}
public void setName(String nameParam)
{
name = nameParam;
}
public String getName()
{
return name;
}
public void setAddress(String addressParam)
{
address = addressParam;
}
public String getAddress()
{
return address;
}
public void setValue(double valueParam)
{
value = valueParam;
}
public double getCarCost()
{
return value;
}
public void printCustomerDetails()
{
System.out.println("The identity of the customer is: " + identity);
System.out.println("The name of the customer is: " + name);
System.out.println("The address of the customer is: " + address);
System.out.println("The value of the customers car is: " + value + "\n");
}
public void bookingValue()
{
//Ive tried messing around with a for loop here but i cant seem to get it working
}
}