📄 test.java
字号:
package org.fangsoft.testcenter.model;
public class Test {
private Question[] questions = new Question[3];
private int counter;
/**
* Constructor for Test
*/
public Test() {
super();
}
/**
* Constructor for Test with a String
* @param aText The text
*/
public Test(String aText) {
System.out.println(aText);
generate();
}
public void addQuestion(Question aQuestion) {
questions[counter++] = aQuestion;
}
public Question[] getQuestions() {
return questions;
}
public void setQuestions(Question[] questions) {
this.questions = questions;
}
public int getQuestionCount() {
return questions.length;
}
public Question getQuestion(int index) {
return questions[index];
}
public void generate() {
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
}
protected void finalize() throws Throwable {
System.out.println("Finalize called on " + this);
super.finalize();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -