Skip to content

Instantly share code, notes, and snippets.

@rokon12
Created September 6, 2013 20:42

Revisions

  1. rokon12 created this gist Sep 6, 2013.
    57 changes: 57 additions & 0 deletions Account.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,57 @@
    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);
    }