⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testcenter.java

📁 远程电子考试系统
💻 JAVA
字号:
package fangsoft.testcenter.driver;

import dbconnect.DbConnect;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import fangsoft.testcenter.model.CertTest;
import fangsoft.testcenter.model.Console;
import fangsoft.testcenter.model.Constants;
import fangsoft.testcenter.model.Customer;
import fangsoft.testcenter.model.PracticeTest;
import fangsoft.testcenter.model.Test;
import fangsoft.testcenter.model.Testable;

public class TestCenter {

	public static void main(String[] args) throws IOException, SQLException {
		DbConnect dbcon=new DbConnect();
		dbcon.connect();
			Console console = new Console();
			Testable myTest = null;
			Test test=null;
			String gd;
			gd = console.getDate();
			System.out.println("选择参加的考试: ");
			System.out.println("1.fangsoft Java practice 知识测试选择1");
			System.out.println("2. fangsoft Java certification知识测试选择2");
			String type = "", arg = "";
			BufferedReader buf = new BufferedReader(
					new InputStreamReader(System.in));
			try {
				type = buf.readLine();
			} catch (IOException e) {
				// TODO 自动生成 catch 块
				e.printStackTrace();
			}
			if (type.equals("1"))
				arg = "practice";
			else if (type.equals("2"))
				arg = "certification";
			else
				System.exit(0);
			if (arg.equalsIgnoreCase("certification")) {
				test = new CertTest();
			} else if (arg.equalsIgnoreCase("practice")) {
				test = new PracticeTest();
			} else {
				System.out.println("输入的是不合法的考试类型. "
						+ "只有 PRACTICE 和 CERTIFICATION 类考试!");
				return;
			}
			boolean generated = test.generate(DbConnect.getConnction());
			if (!generated) {
				System.out.println("Test could not be generated. " +
				"Check for other details. Test system terminated.");
				return;
				}
			//myTest = Test.load(Constants.PERSIST_FILE_NAME);
			myTest=test;
			BufferedReader br = new BufferedReader(new InputStreamReader(
					System.in));
			int count = 0;
			String userId = null, password;
			int MAX_RETRIES = 3;
			Customer customer = null;
			ResultSet rs;
			Statement stmt;
			String limit_time = null, number = null;
			stmt = (dbcon.getConnction()).createStatement();
			rs = stmt
					.executeQuery("select limit_time,total_num from test_paper where test_name='java web知识测试'");
			while (rs.next()) { // 游标象后移动
				limit_time = rs.getString("limit_time");
				number = rs.getString("total_num");
			}
			System.out.println("欢迎你,参加fangsoft考试中心的考试!");
			System.out.println("今天是" + gd);
			String str1 = System.getProperty("os.name");
			System.out.println("你的操作系统是" + str1);
			System.out.println("参加考试前请先登录,输入完成后按Enter确认:");
			for (count = 0; count < MAX_RETRIES; count++) {
				System.out.println("输入用户名称:");
				userId = br.readLine();
				System.out.println("输入用户密码:");
				password = br.readLine();

				if (Customer.login(userId, password, dbcon.getConnction())) {
					break;
				}
				System.out.println("用户名或密码错误不能登录,重新登录." + "登录" + MAX_RETRIES
						+ "次不成功,系统将退出." + "这是" + (count + 1) + "次");
			}
			if (count == MAX_RETRIES) {
				System.out.println("登录" + MAX_RETRIES + "次不成功,系统退出");
				System.exit(0);
			}
			System.out.println("确认参加考试吗?");
			System.out.println("1. 是: y");
			System.out.println("2. 否,退出: n");
			BufferedReader br1 = new BufferedReader(
					new InputStreamReader(System.in));
			String theRead = br1.readLine();

			if (theRead.equals("n")) {
				System.out.println("系统退出!");
				System.exit(0);
			} else {
				System.out.println("==========开始考试==========");
				System.out.println("考试名称: fangsoft Java知识测试");
				System.out.println("考试简述: www.fangsoft.org的java测试");
				System.out.println("考试问题:"+number);
				System.out.println("考试时间:"+limit_time+"分钟");
				System.out.println("现在参加考试吗?");
				System.out.println("1. 是:      y");
				System.out.println("2. 否,退出: n");
			}
			BufferedReader br2 = new BufferedReader(
					new InputStreamReader(System.in));
			String theRead2 = br2.readLine();
			if (theRead2.equals("y")) {
				;
			} else {
				System.out.println("系统退出!");
				System.exit(0);
			}


			System.out.println(Constants.APPNAME + " " + Constants.APPVERSION);
			
			//myTest = Test.load(Constants.PERSIST_FILE_NAME);
			Console.displayTestProperties(myTest);
			Console.presentTest(myTest, dbcon.getConnction(), userId);
			FindResult fbn=new FindResult();
	}

}

⌨️ 快捷键说明

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