网页资讯视频图片知道文库贴吧地图采购
进入贴吧全吧搜索

 
 
 
日一二三四五六
       
       
       
       
       
       

签到排名:今日本吧第个签到,

本吧因你更精彩,明天继续来努力!

本吧签到人数:0

一键签到
成为超级会员,使用一键签到
一键签到
本月漏签0次!
0
成为超级会员,赠送8张补签卡
如何使用?
点击日历上漏签日期,即可进行补签。
连续签到:天  累计签到:天
0
超级会员单次开通12个月以上,赠送连续签到卡3张
使用连续签到卡
08月08日漏签0天
javase吧 关注:61,880贴子:983,791
  • 看贴

  • 图片

  • 吧主推荐

  • 视频

  • 游戏

  • 3回复贴,共1页
<<返回javase吧
>0< 加载中...

java小作业,求大神帮忙。。。

  • 只看楼主
  • 收藏

  • 回复
  • 轮回涛
  • 初二年级
    11
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

大神在哪里?快来帮帮我。。。


  • 龙_少丶
  • 六年级
    9
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
interface Salary{
public float charge();
}
class PersonTest{
private String name;
private int age;
private float salary;
PersonTest(){
}
PersonTest(String name, int age) {
this.name = name;
this.age = age;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public float getSalary() {
return salary;
}
public void setSalary(float salary) {
this.salary = salary;
}
}
class CalculateTime extends PersonTest implements Salary{
private int worktime;
private float pricetime;
CalculateTime() {
super();
}
public CalculateTime(String name, int age,int worktime,float pricetime) {
super(name, age);
this.worktime = worktime;
this.pricetime = pricetime;
super.setSalary(charge());
}
@Override
public float charge() {
return worktime*pricetime;
}
}
class CalculateNum extends PersonTest implements Salary{
private int worknum;
private float workprice;
public CalculateNum() {
super();
}
@Override
public float charge() {
return this.worknum*this.workprice;
}
public CalculateNum(String name, int age,int worknum,float workprice) {
super(name, age);
this.worknum = worknum;
this.workprice = workprice;
setSalary(charge());
}
public int getWorknum() {
return worknum;
}
public void setWorknum(int worknum) {
this.worknum = worknum;
}
public float getWorkprice() {
return workprice;
}
public void setWorkprice(float workprice) {
this.workprice = workprice;
}
}
class CalculateBargain extends PersonTest implements Salary{
private int base;
private int worknum;
private float workprice;
public CalculateBargain(String name, int age,int base,int worknum,float workprice) {
super(name, age);
this.base = base;
this.worknum = worknum;
this.workprice = workprice;
super.setSalary(charge());
}
@Override
public float charge() {
return base + worknum*workprice;
}
public int getBase() {
return base;
}
public void setBase(int base) {
this.base = base;
}
public int getWorknum() {
return worknum;
}
public void setWorknum(int worknum) {
this.worknum = worknum;
}
public float getWorkprice() {
return workprice;
}
public void setWorkprice(float workprice) {
this.workprice = workprice;
}
}
public class Test {
public static void main(String[] args) {
CalculateTime Ctime = new CalculateTime("Tom",22,40,8);
CalculateNum Cnum = new CalculateNum("Mike",19,800,3);
CalculateBargain Cbar = new CalculateBargain("Lee",33,1000,800,2);
System.out.println("计时工:"+Ctime.getName()+"的工资是 "+Ctime.getSalary());
System.out.println("计件工:"+Cnum.getName()+"的工资是 "+Cnum.getSalary());
System.out.println("合同工:"+Cbar.getName()+"的工资是 "+Cbar.getSalary());
}
}


2025-08-08 12:44:36
广告
不感兴趣
开通SVIP免广告
  • 龙_少丶
  • 六年级
    9
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼


登录百度账号

扫二维码下载贴吧客户端

下载贴吧APP
看高清直播、视频!
  • 贴吧页面意见反馈
  • 违规贴吧举报反馈通道
  • 贴吧违规信息处理公示
  • 3回复贴,共1页
<<返回javase吧
分享到:
©2025 Baidu贴吧协议|隐私政策|吧主制度|意见反馈|网络谣言警示