求java大神。。。

作业二:
饲养员类,动物类,食物类。实现饲养员给动物喂食物。
作业三:
创建一个账户Account类,该类有id:账户号码(长整数),password:账户密码,name:真实姓名,personId:身份证号码 字符串类型,email:客户的电子邮箱,balance:账户余额.方法:deposit: 存款方法,参数是double型的金额;withdraw:取款方法,参数是double型的金额.构造方法:有参和无参,有参构造方法用于设置必要的属性

第1个回答  2015-05-30
你这2个作业都是把具体的类的属性和方法提取出来,然后生成不同的类。在相互调用就可以了。这个是思路。本回答被网友采纳
第2个回答  2015-05-29
作业二具体是什么?追问

就是举一个例子就可以了。。

追答

作业二不知道要怎么说。

作业三代码:

public class Account {
long id;
String password, name, personId,email;
double balance;
Account(){

}
Account(long id,String password,String personId,String email){
this.id=id;
this.password=password;
this.personId=personId;
this.email=email;
this.balance=0;
}
void deposit(double money){
this.balance+=money;
}
void withdraw(double money){
this.balance-=money;
}
}

作业二不知道要怎么说。

作业三代码:

public class Account {
long id;
String password, name, personId,email;
double balance;
Account(){

}
Account(long id,String password,String personId,String email){
this.id=id;
this.password=password;
this.personId=personId;
this.email=email;
this.balance=0;
}
void deposit(double money){
this.balance+=money;
}
void withdraw(double money){
this.balance-=money;
}
}

相似回答