Project 2... 0
Project 2... 0
Term Project
Student Name: Mohammed Ashibli Student ID: 210985 .
Full code :
class Account {
private int accountNumber;
private String accountHolderName;
private double balance;
@Override
public void withdraw(double amount) {
@Override
public void withdraw(double amount) {
savingsAccount.deposit(50.0);
savingsAccount.withdraw(20.0);
savingsAccount.checkAccount();
savingsAccount.toString();
System.out.println();
currentAccount.deposit(100.0);
currentAccount.withdraw(250.0);
currentAccount.checkAccount();
currentAccount.toString();
}
}
COMP2108 – Object Oriented Programming
Term Project
Additional Attributes:
Additional Methods:
The CurrentAccount class also inherits from the Account class, introducing an overdraft limit attribute.
The withdraw method is overridden to permit overdrafts up to the specified limit.
Design Decisions:
Encapsulation:
All attributes in the Account, SavingsAccount, and CurrentAccount classes are private, ensuring proper
encapsulation. Access to these attributes is provided through getters and setters.
Abstract Methods:
The use of abstract methods in the Account class enforces a common interface for all account types.
Subclasses must provide their implementation for deposit, withdrawal, and checking account balance.
Final Methods:
COMP2108 – Object Oriented Programming
Term Project
The toString() method is marked as final in the Account class to prevent subclasses from overriding it.
This decision is made to maintain consistency in printing account details across all subclasses.
In the SavingsAccount class, the withdraw method incorporates a minimum balance requirement to
ensure that the account always maintains a specified minimum balance.
Overdraft Limit:
The CurrentAccount class introduces an overdraft limit attribute, and the withdraw method is
overridden to allow overdrafts up to the specified limit. This design decision provides flexibility for
different types of accounts with varying features.
Any changes you made apart from the given (vairables, methods, overrides):
No changes.