某公司的雇员分为以下若干类:
    Employee:这是所有员工总的父类,
        属性:
            员工的姓名,员工的生日月份。
        方法:getSalary(intmonth)
            根据参数月份来确定工资,如果该月员工过生日,则公司会额外奖励100 元。

SalariedEmployee:
        Employee 的子类,拿固定工资的员工。
        属性:月薪

HourlyEmployee:
        Employee 的子类, 按小时拿工资的员工,每月工作超出160 小时的部分按照1.5 倍工资发放。
        属性:每小时的工资、每月工作的小时数

SalesEmployee:
        Employee 的子类,销售人员,工资由月销售额和提成率决定。
        属性:月销售额、提成率

BasePlusSalesEmployee:
        SalesEmployee 的子类,有固定底薪的销售人员,工资 由底薪加上销售提成部分。
        属性:底薪。

根据要求创建 SalariedEmployee 、 HourlyEmployees 、SaleEmployee 和 BasePlusSalesEmployee四个类的对象各一个,
    并计算某个月这四个对象的工资。

注意:要求把每个类都做成完全封装,不允许非私有化属性。

主方法main:

public class Test {public static void main(String[] args) {  //主方法mainEmployee salariedEmployee = new SalariedEmployee("小月",10,5000);Employee hourlyEmployee = new HourlyEmployee("小花",10,10,180);Employee salesEmployee = new SalesEmployee("小明",6,2000,2);Employee basePlusSalesEmployee = new BasePlusSalesEmployee("小艾",5,1000,2,3000);int salary = salariedEmployee.getSalary(10);   //是生日的工资System.out.println(salariedEmployee.getName()+"的月薪是:" + salary);/*int salary = salariedEmployee.getSalary(10);   //不是生日的工资System.out.println(salariedEmployee.getName()+"的月薪是:" + salary);*/int salary1 = hourlyEmployee.getSalary(10);  //是生日的工资System.out.println(hourlyEmployee.getName()+"的月薪是:" + salary1);/*int salary1 = hourlyEmployee.getSalary(2);  //不是生日的工资System.out.println(hourlyEmployee.getName()+"的月薪是:" + salary1);*/int salary2 = salesEmployee.getSalary(6); // 是生日的工资System.out.println(salesEmployee.getName()+"的月薪是:" + salary2);/*int salary2 = salesEmployee.getSalary(3); // 是生日的工资System.out.println(salesEmployee.getName()+"的月薪是:" + salary2);*/int salary3 = basePlusSalesEmployee.getSalary(5);//是生日工资System.out.println(basePlusSalesEmployee.getName()+"的月薪是:" + salary3);/*int salary3 = basePlusSalesEmployee.getSalary(3);//不是生日工资System.out.println(basePlusSalesEmployee.getName()+"的月薪是:" + salary3);*/}
}

员工总的父类Employee:

public class Employee {  //这是所有员工总的父类private String name;private int month;public Employee() {}public Employee(String name, int month) {this.name = name;this.month = month;}public String getName() {return name;}public void setName(String name) {this.name = name;}public int getMonth() {return month;}public void setMonth(int month) {this.month = month;}public int getSalary(int month){   //让子类去重写return 0;}
}

子类SalariedEmployee:

/*
SalariedEmployee:Employee 的子类,拿固定工资的员工。属性:月薪*/
public class SalariedEmployee extends Employee{  //拿固定工资的员工private int yueXin;public SalariedEmployee(int yueYin) {this.yueXin = yueYin;}public SalariedEmployee(String name, int month, int yueXin) {super(name, month);this.yueXin = yueXin;}public int getYueXin() {return yueXin;}public void setYueXin(int yueXin) {this.yueXin = yueXin;}@Overridepublic int getSalary(int month) {if (month == getMonth()){return getYueXin()+100;}else {return getYueXin();}}
}

子类HourlyEmployee:

/*
HourlyEmployee:Employee 的子类, 按小时拿工资的员工,每月工作超出160 小时的部分按照1.5 倍工资发放。属性:每小时的工资、每月工作的小时数*/
public class HourlyEmployee extends Employee {  //按小时拿工资的员工private int meiXiaoShiGongZi;private int meiYueGongZuoXiaoShiSshu;public HourlyEmployee(int meiXiaoShiGongZi, int meiYueGongZuoXiaoShiSshu) {this.meiXiaoShiGongZi = meiXiaoShiGongZi;this.meiYueGongZuoXiaoShiSshu = meiYueGongZuoXiaoShiSshu;}public HourlyEmployee(String name, int month, int meiXiaoShiGongZi, int meiYueGongZuoXiaoShiSshu) {super(name, month);this.meiXiaoShiGongZi = meiXiaoShiGongZi;this.meiYueGongZuoXiaoShiSshu = meiYueGongZuoXiaoShiSshu;}public int getMeiXiaoShiGongZi() {return meiXiaoShiGongZi;}public void setMeiXiaoShiGongZi(int meiXiaoShiGongZi) {this.meiXiaoShiGongZi = meiXiaoShiGongZi;}public int getMeiYueGongZuoXiaoShiSshu() {return meiYueGongZuoXiaoShiSshu;}public void setMeiYueGongZuoXiaoShiSshu(int meiYueGongZuoXiaoShiSshu) {this.meiYueGongZuoXiaoShiSshu = meiYueGongZuoXiaoShiSshu;}public int getSalary(int month) {if (getMeiYueGongZuoXiaoShiSshu() > 160) {if (month == getMonth()) {double v = (getMeiYueGongZuoXiaoShiSshu() - 160) * (1.5 * getMeiXiaoShiGongZi());int i = getMeiXiaoShiGongZi() * 160;return (int) (v + i + 100);}else {double v = (getMeiYueGongZuoXiaoShiSshu() - 160) * (1.5 * getMeiXiaoShiGongZi());int i = getMeiXiaoShiGongZi() * 160;return (int) (v + i);}} else {if (month == getMonth()) {int i = (getMeiXiaoShiGongZi() * getMeiYueGongZuoXiaoShiSshu()) + 100;return i;} else {int i = getMeiXiaoShiGongZi() * getMeiYueGongZuoXiaoShiSshu();return i;}}}
}

子类SalesEmployee:    销售人员

/*
SalesEmployee:Employee 的子类,销售人员,工资由月销售额和提成率决定。属性:月销售额、提成率*/
public class SalesEmployee extends Employee {   //销售人员,工资由月销售额和提成率决定private int yueXiaoShouE;private double tiChengLv;public SalesEmployee(int yueXiaoShouE, double tiChengLv) {this.yueXiaoShouE = yueXiaoShouE;this.tiChengLv = tiChengLv;}public SalesEmployee(String name, int month, int yueXiaoShouE, double tiChengLv) {super(name, month);this.yueXiaoShouE = yueXiaoShouE;this.tiChengLv = tiChengLv;}public int getYueXiaoShouE() {return yueXiaoShouE;}public void setYueXiaoShouE(int yueXiaoShouE) {this.yueXiaoShouE = yueXiaoShouE;}public double getTiChengLv() {return tiChengLv;}public void setTiChengLv(double tiChengLv) {this.tiChengLv = tiChengLv;}@Overridepublic int getSalary(int month) {if (month == getMonth()) {double v = (getYueXiaoShouE() * getTiChengLv());int v1 = (int) v + 100;return v1;} else {double v = (getYueXiaoShouE() * getTiChengLv());return (int) v;}}
}

子类:BasePlusSalesEmployee

/*
BasePlusSalesEmployee:SalesEmployee 的子类,有固定底薪的销售人员,工资 由底薪加上销售提成部分。属性:底薪。*/
public class BasePlusSalesEmployee extends SalesEmployee{  //有固定底薪的销售人员private int diXin;public BasePlusSalesEmployee(int yueXiaoShouE, double tiChengLv, int diXin) {super(yueXiaoShouE, tiChengLv);this.diXin = diXin;}public BasePlusSalesEmployee(String name, int month, int yueXiaoShouE, double tiChengLv, int diXin) {super(name, month, yueXiaoShouE, tiChengLv);this.diXin = diXin;}public int getDiXin() {return diXin;}public void setDiXin(int diXin) {this.diXin = diXin;}@Overridepublic int getSalary(int month) {if (month == getMonth()){double v = getDiXin() + (getYueXiaoShouE() * getTiChengLv());return (int) (v+100);}else {double v = getDiXin() + (getYueXiaoShouE() * getTiChengLv());return (int) v;}}
}

某公司的雇员分为以下若干类: Employee:这是所有员工总的父类.属性:员工的姓名,员工的生日月份。 方法:getSalary(intmonth)相关推荐

  1. Cola公司的雇员分为以下若干类:(知识点:多态) 4.1 ColaEmployee :这是所有员工总的父类,属性:员工的姓名,员工 的生日月份。方法:getSalary(int month) 根据

    Cola公司的雇员分为以下若干类:(知识点:多态) 4.1 ColaEmployee :这是所有员工总的父类,属性:员工的姓名,员工 的生日月份.方法:getSalary(int month) 根据参 ...

  2. 某公司的雇员分为以下若干类: Employee:这是所有员工总的父类, 属性: 员工的姓名,员工的生日月份。 方法:getSalary(

    代码 /*某公司的雇员分为以下若干类:Employee:这是所有员工总的父类,属性:员工的姓名,员工的生日月份.方法:getSalary(intmonth)根据参数月份来确定工资,如果该月员工过生日, ...

  3. 某公司的雇员分为以下若干类:

    某公司的雇员分为以下若干类: Employee: ​ 这是所有员工总的父类, ​ 属性:员工的姓名,员工的生日月份. ​ 方法:getSalary(int month) 根据参数月份来确定工资,如果该 ...

  4. 某公司的雇员分为以下若干类;

    某公司的雇员分为以下若干类: Employee:这是所有员工总的父类, 属性:员工的姓名,员工的生日月份. 方法:getSalary(int month) 根据参数月份来确定工资,如果该月员工过生日, ...

  5. 某公司的雇员分为以下若干类 7-12

    题目:某公司的雇员分为以下若干类写一个程序,把若干各种类型的员工放在一个Employee数组里,写一个方法,打印出某月每个员工的工资数额. 注意:要求把每个类都封装,不允许非私有化属性. Employ ...

  6. # 封装,抽象类,继承,重写java编程题 问题描述 ``` 某公司的雇员分为以下若干类: Employee:这是所有员工总的父类,属性:员工的姓名,员工的生日月份。 方法:getSalary(int

    封装,抽象类,继承,重写java编程题 问题描述 某公司的雇员分为以下若干类: Employee:这是所有员工总的父类,属性:员工的姓名,员工的生日月份. 方法:getSalary(int month ...

  7. java编程---某公司的雇员分为以下若干类:Employee:这是所有员工总的父类,属性:员工的姓名,员工的生日月份。方法:getSalary(intmonth)根据参数月份来确定工资。

    题目: 某公司的雇员分为以下若干类: Employee:这是所有员工总的父类, 属性: 员工的姓名,员工的生日月份. 方法:getSalary(intmonth) 根据参数月份来确定工资,如果该月员工 ...

  8. (1)定义一个Circle类,包含一个double型的radius属性代表圆的半径,一个 findArea()方法返回圆的面积。 (2)定义一个类PassObject,在类中定义一个方法printA

      (1)定义一个 Circle 类,包含一个 double 型的 radius 属性代表圆的半径,一个 findArea() 方法返回圆的面积. ( 2 )定义一个类 PassObject ,在类中 ...

  9. 某公司员工分为若干类

    某公司的雇员分为以下若干类: Employee:这是所有员工总的父类,属性:员工的姓名,员工的生日月份. 方法:getSalary(int month) 根据参数月份来确定工资,如果该月员工过生日,则 ...

  10. 四边形可以分为几类_大件物流有哪些公司?大件物流公司的业务可以分为哪几类...

    随着电商市场规模不断扩张,货运渠道,物流公司需求尤为明显,大件物流公司为满足市场需求,大件物流服务需求更是大幅增加,吸引了不少快运企业开始进行竞争.接下来我们就来聊聊大件物流有哪些公司?大件物流行业趋 ...

最新文章

  1. 如何看待 2020 届校招算法岗「爆炸」的情况?
  2. Oracle-PL/SQL基础
  3. 部署xhprof监控php效率(linux版本)
  4. 对标 VS Code,JetBrains 的下一代 IDE :Fleet
  5. React Native的键盘遮挡问题(input/webview里)
  6. Xcode里-ObjC, -all_load, -force_load
  7. 使用Xshell登录AWS的EC2云服务器和开启EC2上允许root+密码方式登录
  8. 学习NA,Dynamips实验环境(工大瑞普)下载地址
  9. 家谱宗族网站源码_云码宗谱网络家谱软件
  10. Go语言和Java的面向对象比较
  11. 工程师思维是什么?芯片工程师要有哪些思维习惯?
  12. ad电阻原理图_Arduino动手做(2)光敏电阻模块
  13. web安全测试用例(网络资源笔记)
  14. matlab 随机相位的正弦信号,利用MATLAB绘制随机相位正弦波.docx
  15. Unity Shader - Built-in管线下优化 multi_compile_fwdbase、multi_compile_fog 变体
  16. 360极速浏览器一键操作 订单速记表selenium +requests爬取 openpyxl +xlrd 操作excel
  17. lua 连接mysql_luasql连接mysql数据库
  18. 投影到此电脑 连接 怎么退出全屏
  19. FigDraw 4. SCI 文章绘图之散点图 (Scatter)
  20. CVTE前端面经(2023)

热门文章

  1. android 编写计时器,Android用5种方式实现自定义计时器, 哪种才是你的菜?
  2. 详述GPS原理及RTK技术应用
  3. SDM439平台出现部分机型SD卡不能识别mmc1: error -110 whilst initialising SD card【学习笔记】...
  4. 华为员工辞职创办芯片公司,身家165亿,胡润榜500强
  5. 车载电子瞬态浪涌保护用瞬态抑制TVS二极管,如何正确选型?
  6. 鸿合一体机触屏没反应怎么办_一体机屏幕触摸不准的原因以及解决方法
  7. 圆和长方形周长相等谁的面积大_周长相等的长方形正方形和圆谁面积最大,谁面...
  8. 看图和步骤教你把dwg转换成pdf格式
  9. JAVA 使用aspose.cad将dwg文件转PDF(每个布局转为一页)
  10. C# IFELanguage接口获取拼音,支持多音字,音调 win10/8.1/7测试通过