Java

OOP GUIDE / WORK

 

BANKACCOUNT CLASS

 

Topics

  • Simple class design, Using objects

 

 

TASK – PART 1 – BANKACCOUNT CLASS

 

You will create and test the following BankAccount class:

 

Instance variables (datafields):

  • balance
  • firstName
  • lastName

 

Constructor

  • It gets two Strings for the names.  The balance is set to zero.

 

Instance methods:

  • void deposit(double amount)

    The value of amount is added to balance.

  • void withdraw(double amount)

The value of amount is remove from balance.

  • String fullName()

    The full name of the account's owner is returned.

boolean inOverdraft()

Returns true if balance is below zero.  Returns false otherwise.

  • String toString()

    The full name of the owner followed by the balance is returned.  For example:

              Donald Trump ($5000000)

 

 

TASK – PART 2 – TESTING YOUR BANKACCOUNT CLASS

 

Create a BankAccountTester class.  Inside the main function, create a BankAccount object and test all of the methods several times.