Menu

Write Class Definition Including Attributes Bankaccount Customer Person Bankid Balance Par Q43790307

  1. Write the class definition including itsattributes

Bank_account

Customer Person

Bank_Id

Balance

parameter constructor

default construtor (name=”*****” id=-111111, balance=0; )

Display

deposit // accepts amount    throws anexception

withdraw // accepts amount

b)

  1. Implement the parameter constructor
  2. Inplement display function and test it firstin the main driver
  3. Implement a deposit function
  4. Implement withdraw that includes exceptionhandling when we attempt to withdraw beyond the balance

A possible solution

  1. withdraw throwsException_no_fund  

  1.    Exception_no_fund   e=new Exception_no_fund   ( “ balancelow”);

   if ( (balance – amount)<0) throw e;

  1. Implement the exception class
  • Exception_no_fund   extendsException
  • private data string message
  • one paramter constructor
  1. In the test driver you need to protect the withdraw method withtry block

try{  withdraw}

  1. After the try block catch the exception in case it isthrown

catch (Exception_no_fund   e){ e.display;}

Expert Answer


Answer to Write the class definition including its attributes Bank_account Customer Person Bank_Id Balance parameter constructor …

OR