Page 145 - CITS - CSA - TP (Volume 2) - Hindi
P. 145

कं  ूटर सॉ वेयर ए ीके शन - CITS




           balance -= amount;

           }

           void displayBalance() {
           System.out.println(“Balance: “ + balance);

           }

           }
           class SavingsAccount extends BankAccount {

           // Overriding the withdraw method of the superclass

           @Override
           void withdraw(double amount) {

           if (balance - amount >= 1000) {

           balance -= amount;

           } else {
           System.out.println(“Insufficient balance”);

           }

           }
           }

           class CurrentAccount extends BankAccount {

           // Overriding the withdraw method of the superclass

           @Override
           void withdraw(double amount) {

           if (balance - amount >= 0) {

           balance -= amount;
           } else {

           System.out.println(“Insufficient balance”);

           }
           }

           }

           public class BankAccountDemo {

           public static void main(String[] args) {
           BankAccount account1 = new SavingsAccount();






                                                           131

                                   CITS : IT & ITES - कं  ूटर सॉ वेयर ए ीके शन - अ ास 99
   140   141   142   143   144   145   146   147   148   149   150