抽象类 [英] abstract class

查看:87
本文介绍了抽象类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做一项任务,以下是问题的一部分:


为大学设计一个程序,以确定是否是学生或教授,很出色。教授杰出的标准是有120多种出版物。学生优秀的标准是平均成绩为3.3。对于教授来说,三类数据余烬将是名称,出版物数量和方法是Outstanding()。


我已经完成了以下代码

I am doing an assignment and following is part of the question:

A program is to be devised for a university to work out whether or not, a student or a professor, is outstanding. The criterion for a professor to be outstanding is to have over 120 publications. The criterion for a student to be outstanding is to have a Grade Point Average of 3.3. For a professor, the three class data embers would be name, number of publications and the method is Outstanding().

I have done the following code


公共抽象类SchoolMember {


//这些是SchoolMember类的属性


字符串名称;

字符串姓氏;

字符串地址;

String contactNumber;


public abstract boolean outstanding();
public abstract class SchoolMember {

//These are the attributes for a SchoolMember class

String name;
String surname;
String address;
String contactNumber;

public abstract boolean outstanding();



公共课教授延伸学校成员{


整数numberOfPublications;


public boolean outstanding(){


if(numberOfPublications> 120)

返回true;


}


}
public class Professor extends SchoolMember {

Integer numberOfPublications;

public boolean outstanding() {

if (numberOfPublications > 120)
return true;

}

}



我在这行代码中遇到错误

public boolean outstanding()


请问some1帮我解决这个问题?


非常感谢

I am being given an error in this line of code
public boolean outstanding()

Can please some1 help me to solve this problem?

Thank you very much

推荐答案

展开 | 选择 | 换行 | 行号



我正在做作业,以下是问题的一部分:


将设计一个程序一所大学,无论是学生还是教授,都要表现出色。教授杰出的标准是有120多种出版物。学生优秀的标准是平均成绩为3.3。对于教授来说,三类数据余烬将是名称,出版物数量和方法是Outstanding()。


我已经完成了以下代码






我在这行代码中遇到错误

public boolean outstanding()


请问some1帮我解决这个问题?


非常感谢
I am doing an assignment and following is part of the question:

A program is to be devised for a university to work out whether or not, a student or a professor, is outstanding. The criterion for a professor to be outstanding is to have over 120 publications. The criterion for a student to be outstanding is to have a Grade Point Average of 3.3. For a professor, the three class data embers would be name, number of publications and the method is Outstanding().

I have done the following code






I am being given an error in this line of code
public boolean outstanding()

Can please some1 help me to solve this problem?

Thank you very much



你的方法指定它返回一个布尔值,但如果你看一下,就会有一个它可能根本不会返回任何内容。

在方法的开头声明一个boolen并初始化它,在if或if else部分中适当地设置它的值并在结尾处返回布尔值方法。

Your method specifies that it returns a boolean but if you look at it, there is a possibility that it might not return anything at all.
Declare a boolen at the start of your method and initialize it, set its value appropriately in the if or if else part and return the boolean at the end of the method.


展开 | 选择 | Wrap | 行号


这篇关于抽象类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆