Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class BankAccount {
- private int balance;
- private String accNum;
- public BankAccount(String a) {
- accNum = a;
- balance = 0;
- }
- public void deposit(int amount) {
- balance = balance + amount;
- }
- public int getBalance() {
- return balance;
- }
- public int withdraw(int amount) throws Exception{
- if (balance>=amount){
- balance-=amount;
- return balance;
- }else{
- throw new Exception("Insufficient balance");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment