chu
package edu.week5;
class Account {
String id;
String name;
int balance = 0;
public Account(){
}
public Account(String id,String name){
this.id = id;
this.name=name;
}
public Account(String id,String name,int balance){
this.id = id;
this.name = name;
this.balance = balance;
}
public String setID(){
return id;
}
public String getName(){
return name;
}
public int setBalance(){
return balance;
}
public int credit(int amount ){
balance += amount;
return balance;
}
public int debit(int amount){
if(amount <= balance){
balance -= amount;
}else{
System.out.print(" Amount exceeded balance ");
}
return balance;
}
public int transferTo(int anotherAccount,int amount){
if(amount <= balance){
amount = anotherAccount;
}else{
System.out.print(" Amount exceeded balance");
}
return balance;
}
public String toString (){
return " Account[id="+id+",name ="+name+" , balance = "+balance+" ] ";
}
}
pa!!!!!!!!!