jeudi 24 septembre 2015

How would i unit test this class?

A bank account has a balance that can be changed by deposits and withdrawals.

Constructs a bank account with a zero balance.

Constructs a bank account with a given balance. @param initialBalance the initial balance

Deposits money into the bank account. @param amount the amount to deposit

Withdraws money from the bank account. @param amount the amount to withdraw

Gets the current balance of the bank account. @return the current balance

 public class BankAccount
        {
           private double balance;

           public BankAccount()
           {
              balance = 0;
           }

           public BankAccount(double initialBalance)
           {
              balance = initialBalance;
           }

           public void deposit(double amount)
           {
              balance = balance + amount;
           }

           public void withdraw(double amount)
           {
              balance = balance - amount;
           }

           public double getBalance()
           {
              return balance;
           }
        }

Aucun commentaire:

Enregistrer un commentaire