choiceaset.java

来自「考试系统」· Java 代码 · 共 67 行

JAVA
67
字号
package paper;

/**
 * @author SpiritRain
 *
 * Choice Answer Set,an implementation of Abstract Answer Set<br />
 * It can support three kind of different choices question<br />
 * Single Choice is what has only one correct answer<br />
 * Multiple Choice is what has one or more correct answer<br />
 * But the GUI of my project only supports Single anmodel<br />
 *  
 */
public class ChoiceASet extends AbstractAnswerSet {
	/**
	 * indicate multiple answer mode
	 */
	public static final int MULTIPLE = 1;
	/**
	 * indicate single answer mode
	 */
	public static final int SINGLE = 0;
	/**
	 * store answer text to discribe answer
	 */
	private String[] ansText;
	/**
	 * answer mode
	 */
	private int mode;

	/**
	 * create an choice answer set with text,key,and mode
	 * @param answer text that discribe the answer
	 * @param key key answer of the question
	 * @param model choice mode
	 */
	public ChoiceASet(String[] ansText, AbstractAnswer key, int model) {
		super(key);
		this.ansText = ansText;
		this.mode = model;
	}

	/* (non-Javadoc)
	 * @see paper.AbstractAnswer#check(java.lang.Object)
	 */
	public boolean check(AbstractAnswer ans) {
		for (int i = 0; i < key.getAnsCount(); i++) {
			/*if someone choice a wrong answer,return score 0*/
			if ((((ChoiceAns) key).getAnswerValue(i)
				!= ((ChoiceAns) ans).getAnswerValue(i))) {
					return false;
			}
		}
		return true;
	}

	/**
	 * get Answer's description
	 * @param index the answer index
	 * @return answer's description String
	 */
	public String getAnswerText(int index) {
		return ansText[index];
	}

}

⌨️ 快捷键说明

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