5.15总结

修改了一下ListView的打印格式,老师和学生显示的格式不一样:

public static class CourseListCell extends ListCell<Course> {
        private final String identity;

        public CourseListCell(String identity) {
            this.identity = identity;
        }

        @Override
        protected void updateItem(Course course, boolean empty) {
            super.updateItem(course, empty);

            if (empty || course == null) {
                setText(null);
                return;
            }

            if (identity.equals("学生")) {
                setText(course.getCourseName() + "\t\t\t\t\t\t\t\t" + course.getTeacherName());
            } else if (identity.equals("老师")) {
                setText(course.getGrade() + "\t\t" + course.getSpeciality() + "\t\t\t\t\t" + course.getCourseName() );
            }
        }
    }
    public static Callback<ListView<Course>, ListCell<Course>> studentCellFactory() {
        return param -> new CourseListCell("学生");
    }
    public static Callback<ListView<Course>, ListCell<Course>> teacherCellFactory() {
        return param -> new CourseListCell("老师");
    }

老师端:

学生端:

 

 二,完善了双击界面:

   @FXML
    void teacherCourseDetails(MouseEvent event) {
        if(event.getClickCount() == 2 && event.getButton() == MouseButton.PRIMARY)
        {
            Stage stage = new Stage();
            stage.setTitle("学习一点通");
            stage.setWidth(1200);
            stage.setHeight(700);
            FXMLLoader fxmlLoader = new FXMLLoader(MyStage.class.getResource("/com/project/resources/fxml/course.fxml"));
            Parent parent = null;
            try {
                parent = fxmlLoader.load();
            } catch (IOException e) {
                e.printStackTrace();
            }
            stage.setScene(new Scene(parent,450,756));
            stage.show();
        }

    }

三,时间差的计算:

1.改善了一些签到的bug:

老师发布签到能获取的小时不能超过今天最晚的时候:

  public static int getHours()
    {
        ZoneId currentZone = ZoneId.systemDefault();
        LocalDateTime now = LocalDateTime.now(currentZone);
        LocalDateTime tomorrow = now.plusDays(1).withHour(0).withMinute(0).withSecond(0);
        Duration duration = Duration.between(now, tomorrow);
        return (int) duration.toHours();
    }

2.签到截止时也不超过今天的计算:

  
        String HH = hours.getValue().toString();
        String MM = hours.getValue().toString();
        String SS = second.getValue().toString();
        // 获取当前系统日期和时间
        LocalDateTime now = LocalDateTime.now();

// 将 ComboBox 中的时间加上去,得到一个新的时间
        LocalDateTime newTime = now.plusHours(Integer.parseInt(HH))
                .plusMinutes(Integer.parseInt(MM))
                .plusSeconds(Integer.parseInt(SS));

// 判断新的时间是否超过今天
        if (newTime.toLocalDate().isEqual(now.toLocalDate())) {
            // 时间未超过今天,将结果格式化为字符串并输出
            String formattedResult = newTime.format(DateTimeFormatter.ISO_LOCAL_TIME);

        } else {
            // 时间已经超过了今天
            AlertInsert.showError("时间不能超过今天!请您重新选择!");
        }

    }

目前主要是删除学生和注销课程时学生查看到课程消息没有什么思路,后面再看看。希望能把学生端的页面显示正式完成吧。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值