20220319 1+X 中级实操考试(id:3097)

* 学生类
 */
public class Student {
	private String name;//学生姓名
	private String pwd;//学生密码

	//补充完成该类的含参构造方法
	public Student(String name,String pwd){
		this.name = name;
		this.pwd = pwd;
	}}

/** * 使用全局变量: sdf,将字符串转换为java.util.Date类型并返回 * @param stringDate * 注意,不能声明任何形式的异常抛出,否则测试用例无法通过 * @return */ public static Date convertFromStringToDate(String stringDate) { // 补全代码: Date date = null; return date; } 

 *处理日期的工具类
 */
public class DateUtil {
	private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	/**
	 * 使用全局变量: sdf,将字符串转换为java.util.Date类型并返回
	 * 注意,不能声明任何形式的异常抛出,否则测试用例无法通过
	 * @param stringDate
	 * @return
	 */
	public static Date convertFromStringToDate(String stringDate) {
		// 补全代码:
		Date date = null;
		try {
			date = sdf.parse(stringDate);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		return date;
	}
	
	/**
	 * 使用全局变量: sdf,将日期转换成字符串
	 * @param date 需要被转换的日期
	 * @return 转换之后的字符串形式的日期
	 */
	public static String convertFromDateToString(Date date) {
		return sdf.format(date);
	}
}
package org.lanqiao.daoimpl;

import java.util.List;

import org.lanqiao.bean.Account;
import org.lanqiao.bean.Info;
import org.lanqiao.dao.SSDao;
import org.lanqiao.db.ObjectUtil;

/**
 * 接口实现类
 */
public class SSDaoImpl implements SSDao{
        /*
         * ObjectUtil工具类提供的方法能实现对数据库的CRUD操作
         * */
        ObjectUtil<Info> infoUtil = new ObjectUtil<Info>();
        ObjectUtil<Account> accountUtil = new ObjectUtil<Account>();

        /**
	 * 依据员工姓名查询员工信息
	 * @param name 员工姓名
	 * @return 有的话返回对象,没有的话返回null
	 */
	public Info queryByName(String name){
                // 请补全sql语句
                String sql = "select * from info where name=?";
                Info i = infoUtil.getOne(sql, Info.class, name); 
                return i;
        }

        /**
	 * 依据员工姓名和绩效日期查询绩效分
	 * @param name 员工姓名
	 * @param time 绩效日期
	 * @return 有的话返回绩效分,没有的话返回0
	 */
	public int queryScore(String name, String time){
                // 请补全sql语句
                String sql = "select * from account where name=? and time=?";
                Account i = accountUtil.getOne(sql, Account.class, name, time); 
                if(i==null){
                        return 0;
                }else{
                        return i.getScore();
                }
        }

        /**
	 * 查询绩效分最高的员工姓名
	 * @return 返回员工姓名
	 */
	public String queryMaxScore(){
                // 请补全sql语句
                String sql = "select * from account order by score desc limit 1";
                Account i = accountUtil.getOne(sql, Account.class); 
                return i.getName();
        }

	/**
	 * 查询平均绩效分最高的员工姓名
	 * @return 返回姓名
	 */
	public String queryMaxAvg() {
                // 请补全sql语句
                String sql = "select * from account where name=(select name from account group by name order by avg(score) desc limit 1)";
                Account i = accountUtil.getOne(sql, Account.class); 
                return i.getName();
        }

        /**
	 * 查询员工绩效分最高分与最低分差值最大的员工姓名
	 * @return 返回姓名
	 */
	public String queryMaxMin() {
                // 请补全sql语句
                String sql = "select * from account where name=(select name from account group by name order by max(score)-min(score) desc limit 1)";
                Account i = accountUtil.getOne(sql, Account.class); 
                return i.getName();
        }
}

  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

爱吃java的羊儿

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值