?? test.java
字號:
package fangsoft.testcenter.model;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
public abstract class Test implements Testable, java.io.Serializable {
private List questions;
public Test() {
super();
questions = new ArrayList();
// TODO Auto-generated constructor stub
}
public Test(String aText) throws SQLException {
this();
System.out.println(aText);
generate(null);
}
public void addQuestion(Question aquestion) {
// questions[counter++]=aQuestion;
questions.add(aquestion);
}
public int getQuestionCount() {
return questions.size();
}
// public abstract boolean generate();
public abstract boolean generate(Connection con) throws SQLException;
/**
* @return
*/
public List getQuestions() {
return questions;
}
public void setQuestions(List question) {
this.questions = question;
}
private String test_name;
public String getTest_name() {
return test_name;
}
public void setTest_name(String test_name) {
this.test_name = test_name;
}
public Question getQuestion(int index) {
if (index >= 0 && index < questions.size())
return (Question) questions.get(index);
return null;
}
public void save(String fileName) {
ObjectOutputStream os = null;
try {
os = new ObjectOutputStream(new FileOutputStream(fileName));
os.writeObject(this);
} catch (Exception ex) {
ex.printStackTrace();
System.exit(1);
} finally {
if (os != null) {
try {
os.close();
} catch (IOException io) {
}
}
}
}
public static Test load(String fileName) {
Test test = null;
ObjectInputStream is = null;
try {
is = new ObjectInputStream(new FileInputStream(fileName));
test = (Test) is.readObject();
} catch (Exception ex) {
System.out.println("Could not load serialized instance.");
System.out.println("Did you run PersistTest?");
System.exit(1);
} finally {
if (is != null) {
try {
is.close();
} catch (IOException io) {
}
}
}
return test;
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -