📄 lrecord.java
字号:
/*
* This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/).
*/
package ch07.logic;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.*;
import javax.servlet.http.HttpSession;
import ch07.*;
import ch07.global.GlobalObjectProvider;
import ch07.object.unit.*;
import ch07.database.*;
/**
* 针对历史记录相关的逻辑处理类
* @author ShenYK
* @version 1.0
*/
public class LRecord
{
//获得某一用户某一分类的历史记录
public Vector getAllRecords( String sUsername, String sCategoryId )
throws Exception
{
//首先获得对应记录的操作类
DRecord dRecord = (DRecord)GlobalObjectProvider.getDatabaseService(CommonConst.DATABASE_KEY_RECORD);
//如果对应的类没有的话,报错
if ( dRecord == null )
{
throw new Exception("对应的数据操作类没有找到!");
}
Vector vRecords = dRecord.getAllRecords( sUsername, sCategoryId );
return vRecords;
}
//获得某一分类的历史记录分布
public Vector getAllRecords( String sCategoryId )
throws Exception
{
//首先获得对应记录的操作类
DRecord dRecord = (DRecord)GlobalObjectProvider.getDatabaseService(CommonConst.DATABASE_KEY_RECORD);
//如果对应的类没有的话,报错
if ( dRecord == null )
{
throw new Exception("对应的数据操作类没有找到!");
}
Vector vRecords = dRecord.getAllRecords( sCategoryId );
//计算某一分类的历史成绩的各项比例和个数
//0~30,30~60,60~70,70~80,80~90,90~100
int[] iScores = new int[6];
for ( int i=0; i<6; i++ )
{
iScores[i] = 0;
}
for ( int i=0; i<vRecords.size(); i++ )
{
TestRecord testRecord = (TestRecord)vRecords.get(i);
int iScore = testRecord.getTestResult();
if ( iScore >= 0 && iScore<=30 )
{
iScores[0] ++ ;
}
else if ( iScore > 30 && iScore <= 60 )
{
iScores[1] ++ ;
}
else if ( iScore > 60 && iScore <= 70 )
{
iScores[2] ++ ;
}
else if ( iScore > 70 && iScore <= 80 )
{
iScores[3] ++ ;
}
else if ( iScore > 80 && iScore <= 90 )
{
iScores[4] ++ ;
}
else
{
iScores[5] ++ ;
}
}
Vector vResult = new Vector();
for ( int i=0; i<6; i++ )
{
vResult.add( new Integer(iScores[i]) );
}
return vResult;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -