package emppackage;
class Mydate{
private int year;
private int month;
private int day;
public Mydate(int year,int month,int date) {
this.year=year;
this.month=month;
this.day=date;
}
public String toDateString()
{
return year+"年"+month+"月"+day+"日";
}
}
abstract class employee1{
private String name;
private String num;
private Mydate birthday;
abstract public int earnings();
public employee1(String name,String num,Mydate birthday)
{this.name=name;
this.num=num;
this.birthday=birthday;
}
public String toString()
{
return "姓名:"+name+","+"工号:"+num+","+"生日:"+birthday.toDateString();
}
}
class SalariedEmployee extends employee1{
private int monthlysalary;
public SalariedEmployee(String name,String num,Mydate birthday,int monthlysalary){
super(name,num,birthday);
this.monthlysalary=monthlysalary;
}
public int earnings() {
return monthlysalary;
}
public String toString(){
return "月工:"+super.toString();
}
class HourlyEmployee extends employee1{
private int hour;
private int wage;
public HourlyEmployee(String name,String num, Mydate birthday,int hour,int wage){
super(name,num,birthday);
this.hour=hour;
this.wage=wage;
}
public int earnings(){
return hour*wage;
}
public String toString(){
return "小时工"+super.toString();
}
}
public class Employee {
public static void main(String args[]){
employee1 c1[]=new employee1 [4];
Mydate a=new Mydate(2000,11,120);
c1[0]=new SalariedEmployee("张三","202226",a,3000);
System.out.println("c1.toString()");
}
}
怎么修改gets()输出信息