⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 choiceaset.java

📁 考试系统
💻 JAVA
字号:
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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -