永发信息网

java eclipse3.2

答案:3  悬赏:70  手机版
解决时间 2021-04-06 19:39
java eclipse3.2
最佳答案
“习题1 采用抽象类实现”中的“采用抽象类实现”应该可以去掉。


public class company {
//一个保存员工的数组。
private employee all_emp[]=new employee[20];

//1, 添加一个员工。
public void add_emp(employee emp){
for (int i=0;i<20;i++){
if (this.all_emp[i]==null){
this.all_emp[i]=emp;
}else{
System.out.println("公司满员了!");
}
}

}
//2, 通过员工的名字来删除员工。
public boolean del_emp(String name){
for (int i=0;i<20;i++){
if (this.all_emp[i].name==name){
this.all_emp[i]=null;
return true;
}else{
System.out.println("查无此人!");
return false;
}
}
return false;
}
//3, 通过员工的名字来显示员工的工资。
public void show_pay(String name){
for (int i=0;i<20;i++){
if (this.all_emp[i].name==name){
System.out.println(this.all_emp[i].count_pay());
}else{
System.out.println("查无此人!");
}
}
}
//4, 输出所有员工的工资和。
public void show_paysum(){
double temp=0;
for (int i=0;i<20;i++){
if (this.all_emp[i]!=null){
temp=+this.all_emp[i].count_pay();
}
}
System.out.println("所有员工的工资和为:"+temp);
}

}

-------------------------------------------------------------


public abstract class employee {

public String name; //姓名
public double pay; //工资
abstract double count_pay();//抽象方法:计算工资
}

---------------------------------------------


public class hour_worker extends employee {

//工作的小时
private int time_hour;
//每小时工资
private double pay_hour;

//1. 设置工作的小时
public void setTime_hour(int time_hour) {
this.time_hour = time_hour;
}
//2. 设置每小时的工资
public void setPay_hour(int pay_hour) {
this.pay_hour = pay_hour;
}
//3. 重写计算工资方法:
@Override
double count_pay() {
return time_hour*pay_hour;
}

}

----------------------------------------------------------


public class salesMan extends employee{
//销售的总金额
private int sale;

//1. 设置销售的总金额
public void setSale(int sale) {
this.sale = sale;
}

//2. 重写计算工资方法
@Override
double count_pay() {
if (this.sale<10000){
if(sale<0){
System.out.println("销售额不能小于0");
return 0;
}
return this.pay+this.sale*0.1;
}else if(this.sale>1000 && this.sale<100000){
return this.pay+this.sale*0.15;
}else{
return this.pay+this.sale*0.18;
}

}

}
全部回答
you can study how to use the eclipse first.
从无到有这么编写比较好。我老师给了我一堆东西。叫我往里面添加。我现在都弄不明白里面哪里有错。eclipse太高级了太难学了。
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
单选题Girlsusedtotakefeweradvancedmathc
上海浦东第一炸可以加入
表达人虚伪的句子,请问,有什么句子是讽刺一
主卧床头能贴花鸟蝴蝶之类的壁画吗
在横线里填入>、<或=.1小时30分________1.
梅桂花泡水喝有什么好处
请问天龙八部里,十玉,高布怎么做?要什么材
长沙距离张家界多远,从宜昌到张家界的高速怎
荣之跃为什么跟宁晓曦离婚
膝盖扭伤后做了磁共振,磁共振诊断如下,有知
给朋友出国践行的祝福,有歌词求歌名叫什么!
将一副直角三角尺如图放置,已知AE∥BC,则∠
“靴子落地”是什么意思
衢州公积金是否能提取,去哪个地点弄啊?
单词拼写(共10分)76.The day when the Mao
推荐资讯
在Xshell5中怎么把web网页的部分内容添加到re
村里丈量土地多出来的土地面积怎么办
iuni u3怎么设置闹钟铃声
如何学会就事论事 不迁怒与他人??平常都是
“天圆地方”的说法是错误的,应如何证明
2001年左右一款射击游戏,一开始人出现在一个
It’s important us students carefully in
淘宝网 有问题 怎么办 我在淘宝买了个东西 收
我有飞触牌笔记本电脑,开启电源后,只刷屏,
刚做完爱回家接着做
甲午中日战争中,北洋舰队丧失制海权的主要原
【选择题】古代文献中的“江左”又称( )
正方形一边上任一点到这个正方形两条对角线的
阴历怎么看 ?