/** * Created by flo on 9/11/15. */ public abstract class Accounts { // Account Data members private String account; private String name; private String phone; private String ssn; private Double obalance; private Double cbalance; // default constructor public Accounts() { name = ""; account = ""; phone = ""; ssn = ""; obalance = 0.00; cbalance = 0.00; } //Special Constructor in creating an account public Accounts(String name, String account, String phone, String ssn, Double obalance, Double cbalance) { this.name = name; this.account = account; this.phone = phone; this.ssn = ssn; this.obalance = obalance; this.cbalance = cbalance; } // special Abstract method to be used for child class only // O(1) public abstract Double rate(); // get Open balance O(1) public Double getOBalance() { return this.obalance; } // get Closed balance O(1) public Double getCBalance() { return this.cbalance; } // get Account name O(1) public String getName() { return this.name; } // get Account Number O(1) public String getAccNumber() { return this.account; } // get Phone number O(1) public String getPhone() { return this.phone; } // get SSn number O(1) public String getSSN() { return this.ssn; } // Compute monthly interest O(1) public Double computeMonthlyInterest() { Double amount; amount = this.obalance * (1+this.rate()); // closed balanced but lost open balanced return (amount - this.obalance); } // compute closing values for each account O(1) public void computeCloseBalance() { Double ClosedBalance; ClosedBalance = this.obalance + computeMonthlyInterest(); this.cbalance = ClosedBalance; } }