2021-07-23
2021/7/24 6:08:23
本文主要是介绍2021-07-23,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
//Employee.java package cn.campsg.java.experiment.entity; public class Employe { private String name; private int level; private int salary; public String getName() { return name; } public void setName(String name) { this.name = name; } public int getLevel() { return level; } public void setLevel(int level) { this.level = level; } public int getSalary() { return salary; } public void setSalary(int salary) { this.salary = salary; } public Employe(String name, int level, int salary) { this.name = name; this.level = level; this.salary = salary; } public Employe() { this("1",5,5000); } public void work(){ System.out.println(this.name+"按领导的要求完成任务!"); } }
//Hrstaff.java package cn.campsg.java.experiment.entity; public class Hrstaff extends Employe{ public Hrstaff(){ } public Hrstaff(String name){ super(name,5,5000); } public void work(){ super.work(); System.out.println(this.getName()+" 平时需要组织员工多参加运动。"); } public String looupSalary(int level){ //level=em.getLevel(); if(level>=1&&level<=5){ return "每月补贴500元"; //System.out.println("每月补贴500元"); } else if(level>=6&&level<=9){ return "每月补贴800元"; //System.out.println("每月补贴800元"); } else if(level>=10&&level<=15){ return "每月补贴1000元"; //System.out.println("每月补贴1000元"); } else{ return "不存在对应职级。"; //System.out.println("不存在对应职级。"); } } }
//Company.java package cn.campsg.java.experiment; import cn.campsg.java.experiment.entity.Employe; import cn.campsg.java.experiment.entity.Hrstaff; public class Company extends Hrstaff { public Company(){} public void appraisals(Employe emp){ emp.work(); Hrstaff hr=new Hrstaff(emp.getName()); if(emp.getClass()==hr.getClass()){ hr.setLevel(emp.getLevel()); System.out.println("HR的雇员等级为:"+ hr.getLevel() + "," +hr.looupSalary(hr.getLevel())); } } }
//MainClass.java package cn.campsg.java.experiment; import cn.campsg.java.experiment.entity.Employe; import cn.campsg.java.experiment.entity.Hrstaff; public class MainClass { public static void main(String[] args) { Employe emp=new Employe(); Hrstaff hr=new Hrstaff(); Company com=new Company(); com.appraisals(emp); com.appraisals(hr); } }
这篇关于2021-07-23的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!
- 2024-12-22项目:远程温湿度检测系统
- 2024-12-21《鸿蒙HarmonyOS应用开发从入门到精通(第2版)》简介
- 2024-12-21后台管理系统开发教程:新手入门全指南
- 2024-12-21后台开发教程:新手入门及实战指南
- 2024-12-21后台综合解决方案教程:新手入门指南
- 2024-12-21接口模块封装教程:新手必备指南
- 2024-12-21请求动作封装教程:新手必看指南
- 2024-12-21RBAC的权限教程:从入门到实践
- 2024-12-21登录鉴权实战:新手入门教程
- 2024-12-21动态权限实战入门指南