practicetest.java

来自「远程电子考试系统」· Java 代码 · 共 49 行

JAVA
49
字号
package fangsoft.testcenter.model;

public class PracticeTest extends Test {

	public PracticeTest() {
		// TODO Auto-generated constructor stub
		super();
	}

	public PracticeTest(String aText) {
		super(aText);
		// TODO Auto-generated constructor stub
	}

	public boolean generate() {
		// TODO Auto-generated method stub
		String[] qinit = { "Which is correct?", "int a = new int(1);",
				"int a = new Integer(1);", "*int a = 1;", "Integer a = 1;",
				null, "J2SE stands for:", "Java 2 Special Edition",
				"Java 2 Service Editor",
				"Nothing, It simply stands for itself",
				"*Java 2 Standard Edition", null,
				"Platform independence means:",
				"*Not tied to one hardware or software architecture",
				"Needs no platform", "Difficult to control on a platform",
				"Only one platform can be used", null };
		int i = 0;
		while (i < qinit.length) {
			Question question = new Question();
			question.setText(qinit[i++]);
			String choiceText = qinit[i++];
			while (choiceText != null) {
				Choice choice = new Choice();
				if (choiceText.charAt(0) == '*') {
					choice.setCorrect(true);
					choiceText = choiceText.substring(1);
				}
				choice.setText(choiceText);
				question.addChoice(choice);
				choiceText = qinit[i++];
			} // end inner while loop
			addQuestion(question);
		} // end outer while loop

		return true;
	}

}

⌨️ 快捷键说明

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