Java oop8:聲明員工抽象類,聲明各個(gè)員工的子類繼承抽象類實(shí)現(xiàn)員 工工資計(jì)算的案例

//公司計(jì)算工資:公司員工分為經(jīng)理和普通員工,普通員工又有 計(jì)件員工和銷售員工,
//計(jì)件員工的工資計(jì)算是基本工資加上( 件數(shù)-保底30件)*單價(jià),銷售員工的工資是基本工資+銷售量* 單價(jià)。
//問(wèn)題:聲明員工抽象類,聲明各個(gè)員工的子類繼承抽象類實(shí)現(xiàn)員 工工資計(jì)算的案例,在主函數(shù)中調(diào)用它
//經(jīng)理工資:15000
//計(jì)件員工:5000基本工資 單價(jià):30
//銷售員工:4000基本工資 單價(jià):50(選做)
package a;
public class Student {
public static void main(String[] args) {
yuanGong j=new jiJianYuanGong ("袁工",100,120);
((jiJianYuanGong )j).gongNeng();
yuanGong x=new xiaoShouYuanGong ("袁銷",101,121);
((xiaoShouYuanGong )x).gongNeng();
yuanGong c=new jingLi("景麗",101,121);
((jingLi)c).gongNeng();
}
}
interface kaiHui{
void gongNeng();
}
abstract class yuanGong{
public String name;
public int jianShu;
public int xiaoShouLiang;
public yuanGong(String name,int jianShu,int xiaoShouLiang) {
super();
this.name = name;
this.jianShu = jianShu;
this.xiaoShouLiang = xiaoShouLiang;
}
}
class puTongYuanGong extends yuanGong implements kaiHui{
public puTongYuanGong(String name,int jianShu,int xiaoShouLiang) {
super(name,jianShu,xiaoShouLiang);
}
@Override
public void gongNeng() {
}
}
class jiJianYuanGong? extends puTongYuanGong implements/*接口*/ kaiHui{
public jiJianYuanGong(String name,int jianShu,int xiaoShouLiang) {
super(name,jianShu,xiaoShouLiang);
}
@Override
public void gongNeng() {
System.out.println(this.name+"是計(jì)件員工,工資為"+(5000+jianShu*30));
}
}
class xiaoShouYuanGong? extends puTongYuanGong implements/*接口*/ kaiHui{
public xiaoShouYuanGong(String name,int jianShu,int xiaoShouLiang) {
super(name,jianShu,xiaoShouLiang);
}
@Override
public void gongNeng() {
System.out.println(this.name+"是銷售員工,工資為"+(4000+xiaoShouLiang*50));
}
}
class jingLi extends yuanGong implements kaiHui{
public jingLi(String name,int jianShu,int xiaoShouLiang) {
super(name,jianShu,xiaoShouLiang);
}
@Override
public void gongNeng() {
System.out.println(this.name+"是經(jīng)理,工資為15000");
}
}
