Java学生出勤管理系统
时间: 2023-09-09 21:13:08 浏览: 129
学生出勤系统
学生出勤管理系统主要包含以下几个模块:
1. 学生信息管理:包括学生基本信息、出勤情况、请假情况等。
2. 课程信息管理:包括课程名称、授课教师、上课时间、上课地点等。
3. 出勤情况管理:包括考勤情况、迟到情况、早退情况等。
4. 请假情况管理:包括请假类型、请假原因、请假时间等。
5. 报表统计:对学生出勤情况、请假情况进行统计分析,输出报表。
下面是一个简单的Java学生出勤管理系统的代码示例:
```
import java.util.*;
class Student {
private String name;
private String id;
public Student(String name, String id) {
this.name = name;
this.id = id;
}
public String getName() {
return name;
}
public String getId() {
return id;
}
}
class Attendance {
private Student student;
private boolean isPresent;
private int minutesLate;
private int minutesEarly;
public Attendance(Student student, boolean isPresent, int minutesLate, int minutesEarly) {
this.student = student;
this.isPresent = isPresent;
this.minutesLate = minutesLate;
this.minutesEarly = minutesEarly;
}
public Student getStudent() {
return student;
}
public boolean isPresent() {
return isPresent;
}
public int getMinutesLate() {
return minutesLate;
}
public int getMinutesEarly() {
return minutesEarly;
}
}
class Course {
private String name;
private String teacher;
private String time;
private String location;
private List<Attendance> attendanceList;
public Course(String name, String teacher, String time, String location) {
this.name = name;
this.teacher = teacher;
this.time = time;
this.location = location;
this.attendanceList = new ArrayList<>();
}
public void addAttendance(Attendance attendance) {
attendanceList.add(attendance);
}
public int numPresent() {
int count = 0;
for (Attendance attendance : attendanceList) {
if (attendance.isPresent()) {
count++;
}
}
return count;
}
public int numLate() {
int count = 0;
for (Attendance attendance : attendanceList) {
if (!attendance.isPresent() && attendance.getMinutesLate() > 0) {
count++;
}
}
return count;
}
public int numEarly() {
int count = 0;
for (Attendance attendance : attendanceList) {
if (!attendance.isPresent() && attendance.getMinutesEarly() > 0) {
count++;
}
}
return count;
}
public int numAbsent() {
return attendanceList.size() - numPresent();
}
public String getName() {
return name;
}
public String getTeacher() {
return teacher;
}
public String getTime() {
return time;
}
public String getLocation() {
return location;
}
}
class AttendanceSystem {
private List<Student> studentList;
private List<Course> courseList;
public AttendanceSystem() {
this.studentList = new ArrayList<>();
this.courseList = new ArrayList<>();
}
public void addStudent(Student student) {
studentList.add(student);
}
public void addCourse(Course course) {
courseList.add(course);
}
public List<Student> getStudentList() {
return studentList;
}
public List<Course> getCourseList() {
return courseList;
}
public static void main(String[] args) {
// 创建学生
Student student1 = new Student("张三", "001");
Student student2 = new Student("李四", "002");
Student student3 = new Student("王五", "003");
// 创建课程
Course course1 = new Course("Java程序设计", "张三老师", "周一 9:00-10:30", "教1-101");
Course course2 = new Course("计算机网络", "李四老师", "周二 13:30-15:00", "教1-102");
// 添加学生和课程
AttendanceSystem attendanceSystem = new AttendanceSystem();
attendanceSystem.addStudent(student1);
attendanceSystem.addStudent(student2);
attendanceSystem.addStudent(student3);
attendanceSystem.addCourse(course1);
attendanceSystem.addCourse(course2);
// 添加出勤记录
course1.addAttendance(new Attendance(student1, true, 0, 0));
course1.addAttendance(new Attendance(student2, false, 5, 0));
course1.addAttendance(new Attendance(student3, true, 0, 10));
course2.addAttendance(new Attendance(student1, false, 15, 0));
course2.addAttendance(new Attendance(student2, true, 0, 0));
course2.addAttendance(new Attendance(student3, true, 0, 0));
// 输出报表
for (Course course : attendanceSystem.getCourseList()) {
System.out.println(course.getName() + " 课程报表:");
System.out.println("应到人数:" + course.getAttendanceList().size());
System.out.println("实到人数:" + course.numPresent());
System.out.println("迟到人数:" + course.numLate());
System.out.println("早退人数:" + course.numEarly());
System.out.println("缺勤人数:" + course.numAbsent());
System.out.println();
}
}
}
```
这个简单的Java程序实现了一个学生出勤管理系统,可以管理学生信息和课程信息,并且能够统计出勤情况并输出报表。你可以按照自己的需求进行修改和完善。
阅读全文