自带测试类
源代码:
package testaccount;
public class TestAccount{
public static void main(String args[]){
Account ss=new Account(1122,20000);
ss.setannualInterestRate(4.5);
ss.withDraw(2500);
ss.deposit(3000);
System.out.println("The ss's id is "+ ss.getid());
System.out.println("The ss's balance is "+ ss.getbalance());
System.out.println("The ss's dateCreated is "+ ss.getdateCreated());
}
}
class Account{
private int id=0;
private double balance=0;
private double annualInterestRate=0;
private java.util.Date dateCreated=new java.util.Date();
public Account(){
}
public Account(int newid,int newbalance){
id=newid;
balance=newbalance;
}
public int getid(){
return id;
}
public double getbalance(){
return balance;
}
public double getannualInterestRate(){
return annualInterestRate;
}
public void setid(int newid){
id=newid;
}
public void setbalance(double newbalance){
balance=newbalance;
}
public void setannualInterestRate(double newannualInterestRate){
annualInterestRate=newannualInterestRate;
}
public double getMonthlyInterest(){
return (annualInterestRate/12)/100;
}
public String getdateCreated(){
return dateCreated.toString();
}
public void withDraw(double draw){
balance-=draw;
}
public void deposit(double draw){
balance+=draw;
}
}
运行结果:
创新互联www.cdcxhl.cn,专业提供香港、美国云服务器,动态BGP最优骨干路由自动选择,持续稳定高效的网络助力业务部署。公司持有工信部办法的idc、isp许可证, 机房独有T级流量清洗系统配攻击溯源,准确进行流量调度,确保服务器高可用性。佳节活动现已开启,新人活动云服务器买多久送多久。