testbydifficulty.java

来自「利用JAVA开发的简单考试系统」· Java 代码 · 共 51 行

JAVA
51
字号
package model.condition.test;
import model.persistency.ItemMapper;
import model.connection.*;
import java.util.ArrayList;
import java.sql.*;
//import model.condition.visitor.Visitor;
/**
 * 继承Testable,用于产生某一难度的所有试题
 */
public class TestByDifficulty implements Testable {
	private ArrayList test;
	private String condition;//难度
/**
 * 构造函数
 * @param difficulty   难度
 */
	public TestByDifficulty(String difficulty){
		condition = new String();
		condition = difficulty;
		test = new ArrayList();
	}

/**
 * 用于返回试卷
 * @return   ArrayList类型 返回试卷
 */
	public ArrayList getList(){
		return test;
	}

/**
 * 接收产生某一难度的试卷请求
 */
	public void accept(){
		ItemMapper itemMap = null;
		try{
		Connectable con = new ConnectionAccess("sun.jdbc.odbc.JdbcOdbcDriver");
		//itemMap = ItemMapper.getInstance(con);
                itemMap = new ItemMapper(con);
                test = itemMap.getItemByDifficulty(this.condition);
		}catch(SQLException e){
			System.out.println("sql exception");
		}
		catch(ClassNotFoundException l){
			System.out.println("class not found");
		}

	  }
}

⌨️ 快捷键说明

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