SavingsAccount done, needs docs

This commit is contained in:
2025-04-15 16:30:30 -05:00
parent 06f622ea45
commit 5be70f4643
3 changed files with 14 additions and 16 deletions

View File

@@ -1,3 +1,4 @@
// I put BankAccount and SavingsAccount into a package for the sake of member access
package BankAccount;
public abstract class BankAccount {

View File

@@ -5,42 +5,36 @@ public class SavingsAccount extends BankAccount {
public SavingsAccount(float balance, float annualInterest) {
super(balance, annualInterest);
status = balance >= 25;
updateStatus();
}
public void withdraw(float amount) {
if(status){
if(status) {
super.withdraw(amount);
updateStatus();
}
else{
else {
System.out.println("Cannot withdraw, account is inactive");
}
if(balance < 25)
status = false;
}
public void deposit(float amount) {
if(balance + amount >= 25) {
status = true;
}
super.deposit(amount);
updateStatus();
}
void monthlyProcess() {
int withdrawlOverAmount = 4 - numWithdrawals;
if(withdrawlOverAmount > 0){
serviceCharge += withdrawlOverAmount;
if(numWithdrawals > 4) {
int withdrawlsOverLimit = numWithdrawals - 4;
super.serviceCharge += withdrawlsOverLimit;
}
super.monthlyProcess();
//Update status
updateStatus();
}
public String toString() {
return "Balance: " + balance + "\n Account is active: " + status;
}
//UPDATE_STATUS()?????????
private void updateStatus() { status = balance >= 25; }
}

View File

@@ -1,3 +1,4 @@
// Import the BankAccount package
import BankAccount.*;
public class Main {
@@ -10,5 +11,7 @@ public class Main {
System.out.println(SA);
SA.withdraw(5);
System.out.println(SA);
}
}