我正在使用程序类来尝试测试我的对象类中的方法以查看它们是否工作。这是一个燃气表读数系统,我试图存入资金来偿还客户欠款的余额。为什么我的方法没有返回字符串?
我的对象类组成:
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);
但在存款法我的对象类的我都问了一个字符串说回“余额更新“将被退回。
当我运行测试时,没有字符串返回。把我的头从桌子上拨开 - 我做了一件荒谬的事情吗?
您将需要打印返回值:-) – Bart 2013-03-20 18:34:00