|
import java.util.*; class MyDate{ private int year; private int month; private int day;
public MyDate(int y,int m,int d){//构造函数,构造方法 year=y; month=m; day=d;
}//end public MyDate(int y,int m,int d) public int getYear(){//返回年 return year; }//end getYear()
public int getMonth(){//返回月 return month; }//end getMonth()
public int getDay(){//返回日 return day; }//end getDay() }//end class MyDate class Employee{
private String name; private double salary; private MyDate hireDay;
public Employee(String n,double s,MyDate d){ name=n; salary=s; hireDay=d;
}//end public Employee(String n,double s,MyDate d) public void print(){
System.out.println("名字:"+name+"\n工资:"+salary+"\n雇佣年份:"+hireYear()+"\n"); }//end print()
public void raiseSalary(double byPercent){ salary*=1+byPercent/100; }//end
public int hireYear(){
return hireDay.getYear(); }
完整课后答案请下载附件, 回复本帖子即可查看解压密码
|
|