paper.java

来自「这是一个很好的考试系统的源码」· Java 代码 · 共 41 行

JAVA
41
字号
package com.tarena.exam.model;
import java.util.ArrayList;
import java.util.List;

/**
 * Paper类的对象代表一套试卷,包含若干Question(试题)
 * @author new
 *
 */
public class Paper {
	private String subject;//科目
	private List<Question> allQuestions;//所有试题对象
	private List<String> answers;//学生的选择
	
	public Paper(String subject,List<Question> allQuestions){
		this.subject=subject;
		this.allQuestions=allQuestions;
		answers=new ArrayList<String>();
	}
	
	public Paper(String subject){
		this.subject=subject;
		allQuestions=new ArrayList<Question>();
		answers=new ArrayList<String>();
	}
	
	public boolean  addQuestion(Question q){
		return allQuestions.add(	q);
	}
	
	public String toString(){
		StringBuffer sb=new StringBuffer(subject+"考试试题\n");
		for(int i=0;i<allQuestions.size();i++){
			sb.append((i+1)+","+allQuestions.get(i));
		}
		return sb.toString();
	}
	

}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?