/**
* BankAccount class
*
* @author Suzanne Balik, 14 Oct 2003
*/
public class BankAccount {
private int balance; //in cents
private int accountNumber;
private int monthlyFee;
private double interest;
/**
* Create BankAccount object
*
* @param balance bank account balance in cents
* @param accountNumber account number
* @param monthlyFee monthly fee
* @param interest interest rate (.05 = 5%, .10 = 10%, etc.)
*/
public BankAccount(int balance, int accountNumber,
int monthlyFee, double interest) {
this.balance = balance;
this.accountNumber = accountNumber;
this.monthlyFee = monthlyFee;
this.interest = interest;
}
/**
* Deposit money in bank account
*
* @param amount amount to deposit in cents
* @return new balance
*/
public int deposit(int amount) {
balance += amount;
return balance;
}
/**
* Withdraw money from bank account if
* sufficient funds
*
* @param amount amount to withdraw in cents
* @return String with amount withdrawn and
* new balance if amount > balance
* else returns "Insufficient Funds"
*/
public String withdraw(int amount) {
if (amount > balance)
return "Insufficient funds";
else {
balance -= amount;
return "Withdrawal amount: " + amount +
"\nNew balance: " + balance;
}
}
/**
* Returns String with account info
* @return String with account number,
* balance, monthly fee, interest rate
*/
public String toString() {
return "Account number: " + accountNumber +
"\nBalance: " + balance +
"\nMonthly fee: " + monthlyFee +
"\nInterest rate: " + interest;
}
public void addInterest() {
}
public void applyMonthlyFee() {
}
public int getAccountNumber() {
}
public int getBalance() {
}
public int getMontlyFee() {
}
public double getInterestRate() {
}
public static void main(String[] args) {
BankAccount balik = new BankAccount(1000000, 1234, 100, .10);
BankAccount chissoe = new BankAccount(200, 7890, 100, .05);
System.out.println(balik.toString());
System.out.println(chissoe); //Leave off ".toString()"
System.out.println(chissoe.withdraw(500));
int balikBalance = balik.deposit(1000);
System.out.println("Balik Balance: " + balikBalance);
}
}