// 类名,方法名,属性名 都是拼音;
public class Person
{
//属性
protected String xingming;
protected int gongling;
protected int kuanggong;
protected int qingjia;
protected float xiaoshoue;
//方法
public Person(String xingming, int gongling, int kuanggong, int qingjia, float xiaoshoue)
{
this.xingming = xingming;
this.gongling = gongling;
this.kuanggong = kuanggong;
this.qingjia = qingjia;
this.xiaoshoue = xiaoshoue;
}
public Person()
{
}
public void setXingming(String xingming)
{
this.xingming = xingming;
}
public void setGongling(int gongling)
{
this.gongling = gongling;
}
public void setKuanggong(int kuanggong)
{
this.kuanggong = kuanggong;
}
public void setQingjia(int qingjia)
{
this.qingjia = qingjia;
}
public void setXiaoshoue (float xiaoshoue)
{
this.xiaoshoue = xiaoshoue;
}
public String getXingming()
{
return this.xingming;
}
public int getKuanggong()
{
return this.kuanggong;
}
public int getQingjia()
{
return this.qingjia;
}
public float getXiaoshoue()
{
return this.xiaoshoue;
}
public int getGongling()
{
return this.gongling;
}
public String tostring()
{
return ("---------------"+"\n"+
"姓名:" +this.xingming+"\n"+
"工龄:" +this.gongling+"\n"+
"旷工:" +this.kuanggong+"\n"+
"请假:" + this.qingjia+"\n"+
"销售额: " + this.xiaoshoue+"\n"+
"月薪:"+ Yuexin()+"\n"+
"--------------"+"\n");
}
public float Yuexin()
{
return (float)(700+gongling*100+xiaoshoue*0.05-kuanggong*50-qingjia*30);
}
}
public class Jingli extends Person
{
public Jingli(String xingming,int gongling,int kuanggong,int qingjia,float xiaoshoue)
{
super(xingming,gongling,kuanggong,qingjia,xiaoshoue);
}
public String tostring()
{
return ("---------------"+"\n"+
"姓名:" +this.xingming+"\n"+
"工龄:" +this.gongling+"\n"+
"旷工:" +this.kuanggong+"\n"+
"请假:" + this.qingjia+"\n"+
"销售额: " + this.xiaoshoue+"\n"+
"月薪:"+ Yuexin()+"\n"+
"--------------"+"\n");
}
public float Yunxin()
{
return (float)(1000+gongling*100+xiaoshoue*0.05-kuanggong*50-qingjia*30);
}
}
public class Zhiyuan3 extends Person
{
public Zhiyuan3 (String xingming,int gongling,int kuanggong,int qingjia,float xiaoshoue)
{
super(xingming,gongling,kuanggong,qingjia,xiaoshoue);
}
public String tostring()
{
return ("---------------"+"\n"+
"姓名:" +this.xingming+"\n"+
"工龄:" +this.gongling+"\n"+
"旷工:" +this.kuanggong+"\n"+
"请假:" + this.qingjia+"\n"+
"销售额: " + this.xiaoshoue+"\n"+
"月薪:"+ Yuexin()+"\n"+
"--------------"+"\n");
}
public float Yuexin()
{
return (float)(700+gongling*100+xiaoshoue*0.05-kuanggong*50-qingjia*30);
}
}
public class T
{
public static void main(String[] args)
{
Zhiyuan3 z = new Zhiyuan3 ("小俐",2,3,3,3958.4f);
Jingli j = new Jingli("小苗",4,5,6,98763.4f);
Person p1 = (Person) z;
Person p2 = (Person) j;
System.out.println(p1.toString());
System.out.println(p2.toString());
}
}