Second Assignment

QMCS281

 

 

Create the following Java classes, putting each in its own file and giving each “public” visibility:

 

-- Customer. This class will describe a bank customer. Each customer will have a name and a BankAccount. There should be a constructor to accept the customer name and create a new BankAccount object.  There should also be appropriate accessor and mutator methods. There needs to be deposit and withdrawal methods that accept a double for the amount. Finally, there should be a method to report the balance on the account.

 

-- BankAccount. This class will have the information needed for the bank account. It will have a constructor that sets the balance on the account to zero. Deposit and withdrawal methods will accept a double for the amount. The withdrawal method will return a boolean indicating whether or not the withdrawal was successful – i.e., there were enough funds available to make the withdrawal. It should also have a method to return the balance on the account.

 

-- Banking. This class will contain the main method. It will create two Customer objects. It will then prompt the user for an amount to deposit for each customer and report the balance after that deposit. It will then prompt for a withdrawal for each and report the balance after the withdrawal. This class should not be aware of the BankAccount objects that should be encapsulated within the Customer objects.