我正在從UML圖中編寫程序。不確定參數列表中的「c」是什麼
我將如何表示這種方法?
我知道方法是calculateCharges,但我不確定如何在大括號中表示參數。我確信的是,double是我想返回的類型,CustomerType是我在客戶類中聲明的枚舉。
任何幫助?
+calculateCharge(c:Customer.CustomerType):double
我正在從UML圖中編寫程序。不確定參數列表中的「c」是什麼
我將如何表示這種方法?
我知道方法是calculateCharges,但我不確定如何在大括號中表示參數。我確信的是,double是我想返回的類型,CustomerType是我在客戶類中聲明的枚舉。
任何幫助?
+calculateCharge(c:Customer.CustomerType):double
在這裏你去:
public double calculateCharge(Customer.CustomerType c) {
return c;
}
非常感謝,但是如果它是double的返回類型,我怎樣才能使用變量c,因爲那只是一個整數? – 2015-02-06 03:32:08
@AaronGabriel後來當你調用你傳遞的方法時,值就像這樣'calculateCharge(3)' – Abdi 2015-02-06 03:40:16
這是一個公共方法('+'),名爲'calculateCharge'這需要一個變量,'C',類型Customer.CustomerType'的'並返回'double'。 – Jon 2015-02-06 03:06:08
public Customer.CustomerType calculateCharge(double c) { return(); } – 2015-02-06 03:23:45