Posted by: Ayus May 3, 2011
IT -- Solutions Center[Forum]
Login in to Rate this Post:     0       ?        
@namaste8
- its on java
- i have only done for Checking class
- and tested the class
- similary create two other classes
- operations should be function name(method name)
- for balance transfter: call the method of mortgage or saving class and pass the amount to saving class method  from checking class and vice versa.
- to determine the account via ID, do you hardcore, use arraylist or database. its not clear. for simplicity, you can hardcode in the beginning.

public class Checking {
  private String ID;
  private String name;
  private double balance;
  private double monthlyFee;
  private double amount;

    public String getID() {
        return ID;
    }

    public void setID(String ID) {
        this.ID = ID;
    }

    public double getBalance() {
        return balance;
    }

    public void setBalance(double balance) {
        this.balance = balance;
    }

    public double getMonthlyFee() {
        return monthlyFee;
    }

    public void setMonthlyFee(double monthlyFee) {
        this.monthlyFee = monthlyFee;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
    public String displayInfo(){
        return ("ID:\t"+getID()+"\n"+"Balance:\t"+getBalance()+"\n"+"Name:\t"+getName()+"\n"+"Monthly Fee:\t"+getMonthlyFee());
    }
    public void depositCash(double amount){
        if(amount >0){
          amount = amount+getBalance();
          this.amount=amount;
       }
    }
    public double getNewBalance(){
     return amount;
    }

}

//initialize the class

public class TestClass {
  public static void main(String[]args){
  Saving s = new Saving();
  s.setID("1abc");
  s.setBalance(2000.00);
  s.setName("Test");
  s.setMonthlyFee(20.00);
  s.depositCash(1000);
  System.out.println("Information:\t"+s.displayInfo());
  System.out.println("New Balance:\t"+s.getNewBalance());

  }
}


Last edited: 03-May-11 02:45 PM
Read Full Discussion Thread for this article