プログラム クラスを使用して、オブジェクト クラスのメソッドをテストし、それらが機能するかどうかを確認しようとしています。これはガスメーターの読み取りシステムで、顧客が負っている残高の一部を返済するためにお金を預けようとしています。
私のオブジェクトクラスは以下で構成されています:
package GasAccountPracticeOne;
public class GasAccountPracticeOne
{
private int intAccRefNo;
private String strName;
private String strAddress;
private double dblBalance = 0;
private double dblUnits;
private double dblUnitCost = 0.02;
public GasAccountPracticeOne(int intNewAccRefNo, String strNewName, String strNewAddress, double dblNewUnits)
{
intAccRefNo = intNewAccRefNo;
strName = strNewName;
strAddress = strNewAddress;
dblUnits = dblNewUnits;
}//end of constructor
public GasAccountPracticeOne( int intNewAccRefNo, String strNewName, String `strNewAddress)
{
intAccRefNo = intNewAccRefNo;
strName = strNewName;
strAddress = strNewAddress;
}//end of overloading contructor
public String deposit(double dblDepositAmount)
{
dblBalance = dblBalance - dblDepositAmount;
return "Balance updated";
}
私のプログラムクラスでは、次のように書いています。
System.out.println("Enter deposit amount");
dblDepositAmount=input.nextDouble();
firstAccount.deposit(dblDepositAmount);
しかし、deposit メソッドのオブジェクト クラスでは、return "Balance updated" という文字列が返されるように要求しました。
テストを実行すると、文字列が返されません。テーブルから頭をぶつけて - 私はばかげたことをしましたか?