Write Class Definition Including Attributes Bankaccount Customer Person Bankid Balance Par Q43790307
- 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)
- Implement the parameter constructor
- Inplement display function and test it firstin the main driver
- Implement a deposit function
- Implement withdraw that includes exceptionhandling when we attempt to withdraw beyond the balance
A possible solution
- withdraw throwsException_no_fund
- Exception_no_fund e=new Exception_no_fund ( “ balancelow”);
if ( (balance – amount)<0) throw e;
- Implement the exception class
- Exception_no_fund extendsException
- private data string message
- one paramter constructor
- In the test driver you need to protect the withdraw method withtry block
try{ withdraw}
- 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