一道很基础的题但是由于放假我之间给整不会了尴尬了,具体的要求在图片上,希望能手帮帮忙谢谢!
2条回答 默认 最新
- 卑以自牧w 2021-09-11 22:20关注
#员工类
```java class Csdn { private String name; private int age; private String position; private int salary; public Csdn(){ } public Csdn(String name, int age, String position, int salary) { this.name = name; this.setAge(age); this.setPosition(position); this.setSalary(salary); } public String getName() { return name; } public void setName(String name) { this.name = name; } public int getAge() { return age; } public void setAge(int age) { if (age>=18){ this.age=age; }else{ this.age=18; System.out.println("年龄信息输入有误!默认修改为18!"); } } public String getPosition() { return position; } public void setPosition(String position) { if (position=="售后服务"||position=="销售员"){ this.position=position; }else{ this.position="售后服务"; System.out.println("职位信息输入有误!默认修改为售后服务!"); } } public int getSalary() { return salary; } public void setSalary(int salary) { if (this.getAge()>=18&this.getAge()<=20){ this.salary=1000; }else if (this.getAge()>=21&this.getAge()<=25){ this.salary=1500; }else if (this.getAge()>=26&this.getAge()<=30){ this.salary=2000; }else if (this.getAge()>=31&this.getAge()<=40){ this.salary=3000; }else if (this.getAge()>=41&this.getAge()<=50){ this.salary=3500; }else if (this.getAge()>50){ this.salary=4000; } } public void message(){ System.out.println("姓名:"+this.getName()+"\n"+"年龄:"+this.getAge()+"\n"+ "职位:"+this.getPosition()+"\n"+"薪水:"+this.getSalary()); } } #测试类 ```java public class Employee { public static void main(String[] args) { Csdn csdn = new Csdn("张三",20,"总经理",1000); csdn.message(); Csdn csdn1 = new Csdn("李四", 26, "销售员", 2500); csdn1.message(); } } #具体你自己运行吧 应该是没有问题的
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 1无用
悬赏问题
- ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
- ¥100 为什么这个恒流源电路不能恒流?
- ¥15 有偿求跨组件数据流路径图
- ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
- ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
- ¥15 CSAPPattacklab
- ¥15 一直显示正在等待HID—ISP
- ¥15 Python turtle 画图
- ¥15 stm32开发clion时遇到的编译问题
- ¥15 lna设计 源简并电感型共源放大器