📄 netexamsystem_client.java~130~
字号:
package testovernet;
import java.io.*;
public class NetExamSystem_Client {
public static void main(String[] args) {
// StudentExam student = new StudentExam(10001, "Kay Ding", 24, "Male");
StudentExam student = new StudentExam();
// student.printStudentInfo();
System.out.println("\nWelcome to Self Examination System Over Internet!");
boolean connectable = student.isConnectToServer();
/* try {
String s = tempInput.readLine();
System.out.println(s);
}
catch (Exception e) {
e.printStackTrace();
} */
if (connectable == true) {
System.out.println(
"\nSuccess Connected, Authenticating now please...");
student.setExamStudentInfo();
try {
BufferedReader tempInput
= new BufferedReader(new InputStreamReader(System.in));
OutputStream stuOuput = (student.stuSocket).getOutputStream();
InputStream stuInput = (student.stuSocket).getInputStream();
DataOutputStream stuDataOutput = new DataOutputStream(stuOuput);
DataInputStream stuDataInput = new DataInputStream(stuInput);
ObjectOutputStream stuObjOutput = new ObjectOutputStream(
stuOuput);
ObjectInputStream stuObjInput = new ObjectInputStream(stuInput);
stuObjOutput.writeObject(student);
System.out.println(stuDataInput.readUTF());
String isEligible = stuDataInput.readUTF();
// System.out.println(isEligible);
if (isEligible.equals("Eligible")) {
student.setExamMode();
int questionAmount = student.questionAmount;
String questionType = student.questionType;
stuDataOutput.writeUTF(questionType);
stuDataOutput.writeInt(questionAmount);
System.out.println("\nOK, Let's start: ");
Question[] testPaperAfterExam = new Question[questionAmount];
testPaperAfterExam = student.getTestPaperFromServerAndExam
(questionAmount, stuObjInput);
student.sendTestPaperAfterExamToServer
(questionAmount, testPaperAfterExam, stuObjOutput);
System.out.println("\n\nTest over,Waiting server sending score..."
+"\nCongratulations!"+"\nYour score of this test is: " +
+stuDataInput.readInt());
}
else {
}
stuOuput.close();
stuInput.close();
student.stuSocket.close();
}
catch (Exception e) {
e.printStackTrace();
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -