?? examadmin.java
字號:
package testovernet;
import java.io.*;import javax.swing.*;
public class ExamAdmin {
protected final String NOTEXAMSTUDENT =
"This Student has no right to take the test!";
protected TestPaperAdmin paperAdmin;
protected DatabaseAdmin dataAdmin;
protected ScoreCaculator scoreCaculator;
protected Student eligibleStudent;
protected Question[] paperFromTestPaperAdmin;
protected Question[] TestPaperAfterExamFromStudent;
protected int studentScore; JRadioButton jRadioButton1 = new JRadioButton(); JLabel jLabel1 = new JLabel();
public ExamAdmin() {
paperAdmin = new TestPaperAdmin();
dataAdmin = new DatabaseAdmin(); try { jbInit(); } catch(Exception e) { e.printStackTrace(); }
}
public Student getEligibleStudent() {
return eligibleStudent;
}
public Question[] getPaperFromTestPaperAdmin(String questionType, int num) {
paperFromTestPaperAdmin = new Question[num];
paperFromTestPaperAdmin = paperAdmin.getTestPaper(questionType, num);
return paperFromTestPaperAdmin;
}
public boolean isStudentInDatabase(int testNo, String name) {
boolean isStudent = dataAdmin.queryStudent(testNo, name);
if (isStudent == false) {
System.out.println(NOTEXAMSTUDENT);
}
else {
System.out.println("This Student is eligible to take the test!");
System.out.println("This Detail Infomation of this Student is: ");
eligibleStudent = dataAdmin.getfindStudent();
eligibleStudent.printStudentInfo();
// eligibleStudent = dataAdmin.getfindStudent();
}
return isStudent;
}
public void sendPaperToStudent(String quesType, int quesAmount,
ObjectOutputStream objOutput) {
Question[] testPaper = new Question[quesAmount];
testPaper =getPaperFromTestPaperAdmin(quesType, quesAmount);
for (int i = 0; i < quesAmount; i++) {
testPaper[i].PrintQuestion();
try {
objOutput.writeObject(testPaper[i]);
}
catch (Exception e) {
e.printStackTrace();
}
}
}
public void getTestPaperAfterExamFromStudent
(int quesAmount,ObjectInputStream objInput) {
TestPaperAfterExamFromStudent = new Question[quesAmount];
for (int i = 0; i < quesAmount; i++) {
try {
TestPaperAfterExamFromStudent[i] = (Question) objInput.readObject();
System.out.println(TestPaperAfterExamFromStudent[i].studentAnswer);
System.out.println(paperFromTestPaperAdmin[i].standardAnswer);
}
catch (Exception e) {
e.printStackTrace();
}
}
}
public int caculatorStudentScore(int quesAmount,DataOutputStream dataOutput) {
scoreCaculator= new ScoreCaculator();
studentScore=(int)scoreCaculator.scoreCaculate(quesAmount,paperFromTestPaperAdmin,
TestPaperAfterExamFromStudent);
System.out.println("This student's score is "+studentScore);
try {
dataOutput.writeInt(studentScore);
}catch(Exception e) {
e.printStackTrace();
}
return studentScore;
}
public void recordStudentScoreToDatabase() {
int testNum=eligibleStudent.testNum;
dataAdmin.setStudentScore(testNum,studentScore);
} private void jbInit() throws Exception { jLabel1.setText("jLabel1"); jRadioButton1.setText("jRadioButton1"); }
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -