Skip to content

Instantly share code, notes, and snippets.

@rokon12
Created September 6, 2013 20:42
Show Gist options
  • Save rokon12/6469729 to your computer and use it in GitHub Desktop.
Save rokon12/6469729 to your computer and use it in GitHub Desktop.
package com.rokonoid.demo;
public abstract class Account {
private double initialBalance;
private double interest;
private int transection;
private double bankFee;
public Account(double initialAccount) {
this.initialBalance = initialAccount;
}
public double getBalance() {
return initialBalance;
}
public void endMonth() {
System.out.println();
System.out.println("-----------endMonth()----------");
System.out.println("Interest: " + interest);
System.out.println("Total Transection: " + getTotalTransection());
System.out.println("Bank Fee: " + bankFee);
System.out.println("Total Balance: " + calculateTotalBalance());
System.out.println("-----------endMonth()----------");
System.out.println();
}
private double calculateTotalBalance() {
return (getBalance() - bankFee + interest);
}
protected void addBalance(double amount) {
transection++;
initialBalance += amount;
}
protected void addTransectionFee(double fee) {
bankFee += fee;
}
protected int getTotalTransection() {
return transection;
}
protected void substractBalance(double amount) {
if (getBalance() < amount) {
System.out.println("Insufficient funds");
return;
}
transection++;
initialBalance -= amount;
}
public abstract void diposit(double amount);
public abstract void withdraw(double amount);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment