Java制作简单的单选和多选测试题
题目:
定义考题类(Question)及其子类
完成考题类(Question),单选题(SingleChoice)和多选题(MultiChoice)是其子类
要求:
1)Question包含题干属性(text)
2)Question包含检测标准答案的方法 boolean check(int[] answers)
参数answers:用户提供的答案(注意:单选题只有一个答案)
3)单选题(SingleChoice)和多选题(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方法
方法中提供具体的检查用户答案的逻辑
package Question;
public class Question {
protected String text;//测试题
public Question() { }//无参构造
public Question(String text) {//有参构造
this.text =