Java程序不打印出我指定的所有值

时间:2015-09-15 00:25:19

标签: java debugging testing test-class

因此,在我的Java课程作业中,我们必须修改一个类,然后在Jgrasp中编写一个测试器类,我的测试器类看起来像这样

public class BankAccountTester {
   public static void main(String[]args){
      BankAccount account = new BankAccount(1000);
      account.setFreeTrans(5);
      account.setTransFee(2);
      account.deposit(1000);
      account.withdraw(500);
      account.withdraw(400);
      account.deposit(200);
      System.out.println(account.getBalance());
      System.out.println("expected: 1300");
      account.monthlyCharge();
      System.out.println(account.getBalance());
      System.out.println("expected: 1300");
      account.deposit(1000);
      account.withdraw(500);
      account.withdraw(400);
      account.deposit(500);
      System.out.println(account.getBalance());
      System.out.println("expected: 1900");
      account.monthlyCharge();
      System.out.println(account.getBalance());
      System.out.println("expected: 1900");
      account.deposit(1000);
      account.withdraw(500);
      account.withdraw(400);
      account.deposit(200);
      account.deposit(500);
      account.withdraw(1000);
      System.out.println(account.getBalance());
      System.out.println("expected 1700");
      account.monthlyCharge();
      System.out.println(account.getBalance());
      System.out.println("expected 1698");
      account.deposit(1000);
      account.withdraw(500);
      account.withdraw(400);
      account.deposit(200);
      account.deposit(500);
      account.withdraw(1000);
      account.deposit(100);
      System.out.println(account.getBalance());
      System.out.println("expected 1598");
      account.monthlyCharge();
      System.out.println(account.getBalance());
      System.out.println("expected 1594");
      }
  }

所以我遇到的问题是它没有打印出我打印出来的所有值,它应该打印出看起来像这样的东西:

1300
expected: 1300
1300
expected 1300
1900
expected 1900
1900
expected 1900
1700
expected 1700
1698 
expected 1698
1598
expected 1598
1594
expected 1594

但我得到的只是:

1300.0
expected: 1300
1300.0
expected: 1300
1900.0
expected: 1900
1900.0
expected: 1900

有谁知道这是什么,因为我无法弄清楚它会做到这一点的原因。请注意,此测试是在JGrasp的工作台上完成的。 感谢

0 个答案:

没有答案