コード例 #1
0
 /**
  * Tests the methods of the BankAccount class.
  *
  * @param args not used
  */
 public static void main(String[] args) {
   Address address = new Address("100 Main St", "", "Binghamton", "NY 13905", "USA");
   BankAccount harrysChecking = new BankAccount("Jane Doe", address, 10001);
   harrysChecking.deposit(2000);
   harrysChecking.withdraw(500);
   System.out.println(harrysChecking.getBalance());
   System.out.println("Expected: 1500");
 }
コード例 #2
0
  public static void testDriver(int length) {
    BankAccount b = new BankAccount(0);
    for (int i = 0; i < length; i++) {
      Verify.beginAtomic();

      // switch (Verify.random(1)){
      switch (flag(true)) {
        case 0:
          b.deposit(10);
          break;
        case 1:
          b.withdraw(1);
          break;
      }
      Verify.endAtomic();
    }
  }
コード例 #3
0
  /** Test method for {@link edu.cecs274.BankCustomer#getTotalBalance()}. */
  @Test
  public void testGetTotalBalance() {
    BankAccount oneAccount = new BankAccount(aCustomer, INITIAL_ACCOUNT_NUMBER, INITIAL_BALANCE);
    BankAccount twoAccount = new BankAccount(aCustomer, INITIAL_ACCOUNT_NUMBER + 1);
    BankAccount threeAccount = new BankAccount(aCustomer, INITIAL_ACCOUNT_NUMBER + 2);
    aCustomer.addAccount(oneAccount);
    aCustomer.addAccount(twoAccount);
    aCustomer.addAccount(threeAccount);

    double expected = INITIAL_BALANCE;
    double totalBalance = aCustomer.getTotalBalance();
    assertEquals(expected, totalBalance, DELTA);

    // Adds more money to twoAccount, the change should be reflected in aCustomers totalBalance
    twoAccount.deposit(INITIAL_BALANCE);
    expected = INITIAL_BALANCE * 2;
    totalBalance = aCustomer.getTotalBalance();
    assertEquals(expected, totalBalance, DELTA);
  }
コード例 #4
0
ファイル: TestBank.java プロジェクト: Tigatok/Bank
  public static void main(String[] args) {
    BankAccount ba1 = new ChequeAccount("Jack Black", "Hockey");
    ChequeAccount ca1 = new ChequeAccount("Chris Weidman", "Bunnies");
    ChequeAccount ca2 = new ChequeAccount("Ross Geller", "Dinosaurs");

    ba1.deposit(100);
    ((ChequeAccount) ba1).writeCheque(23);

    SavingsAccount sa1 = new SavingsAccount("David Letterman");
    SavingsAccount sa2 = new SavingsAccount("Jimmy Fallon");
    sa1.deposit(25);
    System.out.println("" + ba1 + ca1 + ca2 + sa1 + sa2);

    BalancePrinter bp = new BalancePrinter();
    bp.reportPrinter(ba1);
    bp.reportPrinter(ca1);
    bp.reportPrinter(ca2);
    bp.reportPrinter(sa1);
    bp.reportPrinter(sa2);
  } // main
コード例 #5
0
 /**
  * Transfers money from the bank account to another account
  *
  * @param amount the amount to transfer
  * @param other the other account
  * @throws InsufficientFundsException if the account cannot cover the withdrawal of this amount
  */
 public void transfer(double amount, BankAccount other) throws InsufficientFundsException {
   withdraw(amount);
   other.deposit(amount);
 }
コード例 #6
0
 /**
  * Transfers money from the bank account to another account
  *
  * @param other the other account
  * @param amount the amount to transfer
  */
 public void transfer(BankAccount other, double amount) {
   withdraw(amount);
   other.deposit(amount);
 }