跪求老师帮忙看下代码,感恩!

来源:2-8 编程练习

Kumal

2021-09-13 18:09:19

相关截图:Test.java

https://img.mukewang.com/climg/613f21de092ba8b307430332.jpg

相关截图:Work.java

https://img.mukewang.com/climg/613f21fa09bb2b5f08110576.jpg

相关截图:TestWork.java

https://img.mukewang.com/climg/613f223e0929edb312750753.jpg

相关截图:DevelopmentWork.java

https://img.mukewang.com/climg/613f229b09a71f7512310776.jpg


相关代码:Test.java

public class Test {
public static void main(String[] args) {
Work w = new Work();
System.out.println("父类信息测试:" + w.work());

TestWork tw = new TestWork("测试工作", 10, 5);
System.out.println("测试工作类信息测试:" + tw.work());

DevelopmentWork dw = new DevelopmentWork("研发工作", 1000, 10);
System.out.println("研发工作类信息测试:" + dw.work());
}
}

相关代码:Work.java

public class Work {
// 属性:工作名
private String name;
// 无参构造方法
public Work() {

}
// 带参构造方法,完成工作类型的赋值
public Work(String name) {
this.setName(name);
}
// 公有的get***/set***方法完成属性封装
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
// 方法:工作描述,描述内容为:开心工作
public String work() {
return "开心工作";
}
}

相关代码:TestWork.java

​public class TestWork extends Work {
// 属性:编写的测试用例个数、发现的Bug数量
private int testWrote;
private int bugFound;
// 编写构造方法,并调用父类相关赋值方法,完成属性赋值
public TestWork() {

}
public TestWork(String name, int testWrote, int bugFound) {
this.setName(name);
this.setTestWrote(testWrote);
this.setBugFound(bugFound);
}
// 公有的get***/set***方法完成属性封装
public int getTestWrote() {
return testWrote;
}
public void setTestWrote(int testWrote) {
this.testWrote = testWrote;
}
public int getBugFound() {
return bugFound;
}
public void setBugFound(int bugFound) {
this.bugFound = bugFound;
}
// 重写运行方法,描述内容为:**的日报是:今天编写了**个测试用例,发现了**bug。其中**的数据由属性提供
public String work() {
return this.getName() + "的日报是:今天编写了" + this.getTestWrote() + "个测试用例,发现了" + this.getBugFound() + "个bug。";
}
}

相关代码:DevelopmentWork.java

public class DevelopmentWork extends Work {
// 属性:有效编码行数、目前没有解决的Bug个数
private int effectiveLine;
private int bugUnsolved;
// 编写构造方法,并调用父类相关赋值方法,完成属性赋值
public DevelopmentWork() {

}
public DevelopmentWork(String name, int effectiveLine, int bugUnsolved) {
this.setName(name);
this.setEffectiveLine(effectiveLine);
this.setBugUnsolved(bugUnsolved);
}
// 公有的get***/set***方法完成属性封装
public int getEffectiveLine() {
return effectiveLine;
}
public void setEffectiveLine(int effectiveLine) {
this.effectiveLine = effectiveLine;
}
public int getBugUnsolved() {
return bugUnsolved;
}
public void setBugUnsolved(int bugUnsolved) {
this.bugUnsolved = bugUnsolved;
}
// 重写运行方法,描述内容为:**的日报是:今天编写了**行代码,目前仍然有**个bug没有解决。其中**的数据由属性提供
public String work() {
return this.getName() + "的日报是:今天编写了" + this.getEffectiveLine() + "行代码,目前仍然有" + this.getBugUnsolved()
+ "个bug没有解决。";
}
}

爱你么么哒!

写回答

1回答

好帮手慕小小

2021-09-13

同学你好,已完成练习,代码实现符合题目要求,代码书写规范,逻辑清晰。另外同学上传到问答区的代码既有源码又有截图,可读性高,很棒哦,继续加油!

祝学习愉快~

0
humal
hp>谢谢小小老师么么哒!

h021-09-13
共1条回复

0 学习 · 9886 问题

查看课程