1.
Create a class Account having the members as given below:
accno int
custname String
acctype String (indicates ‘Savings’ or ‘Current’) { use ENUM)
balance float
Include the following methods in the AccountService class:
boolean isValidAccount(Account account)
void deposit(float amt);
void withdraw(float amt);
float getBalance();
Use ArrayList with 5 account objects. List<Account> , in isValidAccount ()
method check whether given account number is existing or not if then
method should throw AccountNotFoundException
deposit(float amt) method allows you to credit an amount into the current
balance. If amount is negative, throw an exception
InvalidAmountException to block the operation from being performed.
withdraw(float amt) method allows you to debit an amount from the
current balance.
Minimum amount to withdraw is 500, if amt is < 500 throw an exception
InvalidAmountException
Please ensure a minimum balance of Rs.1000/- in the account for savings
account and Rs.5000/- for current account, else throw an exception
InsufficientFundsException and block the withdrawal operation.
Add constructor in Account to which you will pass, accno, custname, acctype
and initial balance and check whether the balance is less than 1000 in case
of savings account and less than 5000 in case of a current account. If so,
then raise a LowBalanceException.
In either case if the balance is negative then raise the
InvalidAmountException exception accordingly.
Classes to be created.
package com.ig.model
Class Account {
Integer accNumber;
String custName;
String type;// String (indicates ‘Savings’ or ‘Current’) { use ENUM)
Float balance;
}
Package com.ig.service
Class AccountService {
List<Account> accountList=new ArrayList<>();
Boolean isValidAccount(int acNumber)
void deposit(float amt);
void withdraw(float amt);
float getBalance();
}
package com.ig.ui
Class AccountTest{
Public static void main(String args[]) {
== call methods
}
}
Package com.ig.exception;
class InsufficientFundsException {
}
Class InvalidAmountException {
}
Class LowBalanceException {
}
Node: submit Zipfile with all java files and screenshot of execution. Name of
file- week1solution.zip