Question
JAVA Make the Account class as an abstract class. Define an abstract method printAccountInfo() which should be implemented by the sub classes. This method should
JAVA
Make the Account class as an abstract class. Define an abstract method printAccountInfo() which should be implemented by the sub classes. This method should display the type of account along with the account details.
public class Account { protected int accountNumber; protected double balance;
// Constructor public Account(int a) { balance = 0.0; accountNumber = a; }
public void deposit(double amount) { if (amount > 0) balance += amount; else System.err.println("Account.deposit(...): " + "cannot deposit negative amount."); }
public void withdraw(double amount) { if (amount > 0) if (balance - amount >= 0) balance -= amount; else System.err.println("Account.withdraw(...): " + "cannot withdraw more than your balance."); else System.err.println("Account.withdraw(...): " + "cannot withdraw negative amount."); }
public double getbalance() { return balance; }
public double getAccountNumber() { return accountNumber; }
public void display() { System.out.println("Account " + accountNumber + " : " + "Balance = " + balance); }
}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started