#定义考题类(Question)及其子类
完成考题类(Question),单选题(SingleChoice)和多选题(MultiChoice)是其子类
要求:
1)Question包含题干属性(text)
2)Question包含检测标准答案的方法 boolean check(int[] answers)
参数answers:用户提供的答案(注意:单选题只有一个答案)
3)单选题(SingleChoice)和多选
- List item
题(MultiChoice)是Question的子类
MultiChoice包含属性:
选项:String[] options
多选标准答案:int[] answers
SingleChoice包含属性:
选项:String[] options
单选标准答案:int answers
4)在MultiChoice实现参数为(String text,String[] options,int[] answers)的构造方法
参数text:题干
参数options:选项
参数answers:多选标准答案(正确选项的序号)
5)在SingleChoice实现参数为(String text,String[] options,int answers)的构造方法
参数text:题干
参数options:选项
参数answers:单选标准答案(正确选项的序号)
6)在SingleChoice和MultiChoice类中重写Question类中的check方法
方法中提供具体的检查用户答案的逻辑
1、定义父类,包含text属性和check方法
public class Question {//定义父类,考题类
private String text;
//题干,字符串用来存储题目
public String getText() {
//text的get方法
return text;
}
public void setText(String

最低0.47元/天 解锁文章
161

被折叠的 条评论
为什么被折叠?



