next up previous
Next: Solution for the class Up: Unit 04 Previous: Reading of numbers using

Exercise: the class BankAccount

Specification: Write a class for handling bank accounts that are characterized by the name and surname of the owner and by the balance of the account in Euro. Implement the methods deposit() and withdraw() and the method toString() to obtain a string containing the information on a bank account.

Example of usage:

public class TestBankAccount {
  public static void main (String[] args) {
    BankAccount ba = new BankAccount("Mario", "Rossi");
    System.out.println("Before the operations: " + ba);
    ba.deposit(1000);
    ba.withdraw(100);
    System.out.println("After the operations:  " + ba);
  }
}


next up previous
Next: Solution for the class Up: Unit 04 Previous: Reading of numbers using