我正在使用一个程序类来尝试测试我的对象类中的方法以查看它们是否有效。这是一个燃气表读数系统,我正在尝试存钱以偿还客户所欠的部分余额。
我的对象类包括:
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);
但是在我的存款方法的对象类中,我要求返回一个返回“余额更新”的字符串。
当我运行测试时,没有返回字符串。把我的头从桌子上敲下来——我做了什么可笑的事吗?