用java实现简单的教室管理系统
时间: 2023-09-30 10:12:21 浏览: 94
好的,教室管理系统可以包括以下功能:
1. 学生管理:添加、删除、修改学生信息
2. 教师管理:添加、删除、修改教师信息
3. 课程管理:添加、删除、修改课程信息
4. 教室管理:添加、删除、修改教室信息
5. 课表管理:排课、修改课表信息
6. 成绩管理:录入学生成绩、查询学生成绩
下面是一个简单的教室管理系统的Java代码:
```java
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class ClassroomManagementSystem {
private List<Student> students;
private List<Teacher> teachers;
private List<Course> courses;
private List<Classroom> classrooms;
private List<Schedule> schedules;
private List<Score> scores;
public ClassroomManagementSystem() {
students = new ArrayList<>();
teachers = new ArrayList<>();
courses = new ArrayList<>();
classrooms = new ArrayList<>();
schedules = new ArrayList<>();
scores = new ArrayList<>();
}
public static void main(String[] args) {
ClassroomManagementSystem system = new ClassroomManagementSystem();
system.run();
}
public void run() {
Scanner scanner = new Scanner(System.in);
while (true) {
System.out.println("请选择操作:");
System.out.println("1. 学生管理");
System.out.println("2. 教师管理");
System.out.println("3. 课程管理");
System.out.println("4. 教室管理");
System.out.println("5. 课表管理");
System.out.println("6. 成绩管理");
System.out.println("0. 退出");
int option = scanner.nextInt();
switch (option) {
case 1:
manageStudents(scanner);
break;
case 2:
manageTeachers(scanner);
break;
case 3:
manageCourses(scanner);
break;
case 4:
manageClassrooms(scanner);
break;
case 5:
manageSchedules(scanner);
break;
case 6:
manageScores(scanner);
break;
case 0:
System.out.println("退出系统");
return;
default:
System.out.println("无效的操作");
break;
}
}
}
private void manageStudents(Scanner scanner) {
while (true) {
System.out.println("请选择学生管理操作:");
System.out.println("1. 添加学生");
System.out.println("2. 删除学生");
System.out.println("3. 修改学生");
System.out.println("4. 查询学生");
System.out.println("0. 返回");
int option = scanner.nextInt();
switch (option) {
case 1:
addStudent(scanner);
break;
case 2:
deleteStudent(scanner);
break;
case 3:
updateStudent(scanner);
break;
case 4:
queryStudent(scanner);
break;
case 0:
return;
default:
System.out.println("无效的操作");
break;
}
}
}
private void addStudent(Scanner scanner) {
System.out.print("请输入学生姓名:");
String name = scanner.next();
System.out.print("请输入学生年龄:");
int age = scanner.nextInt();
System.out.print("请输入学生性别:");
String gender = scanner.next();
System.out.print("请输入学生学号:");
String id = scanner.next();
Student student = new Student(name, age, gender, id);
students.add(student);
System.out.println("添加学生成功");
}
private void deleteStudent(Scanner scanner) {
System.out.print("请输入学生学号:");
String id = scanner.next();
for (int i = 0; i < students.size(); i++) {
if (students.get(i).getId().equals(id)) {
students.remove(i);
System.out.println("删除学生成功");
return;
}
}
System.out.println("找不到学生");
}
private void updateStudent(Scanner scanner) {
System.out.print("请输入学生学号:");
String id = scanner.next();
for (int i = 0; i < students.size(); i++) {
if (students.get(i).getId().equals(id)) {
System.out.print("请输入学生姓名:");
String name = scanner.next();
System.out.print("请输入学生年龄:");
int age = scanner.nextInt();
System.out.print("请输入学生性别:");
String gender = scanner.next();
students.get(i).setName(name);
students.get(i).setAge(age);
students.get(i).setGender(gender);
System.out.println("修改学生成功");
return;
}
}
System.out.println("找不到学生");
}
private void queryStudent(Scanner scanner) {
System.out.print("请输入学生学号:");
String id = scanner.next();
for (Student student : students) {
if (student.getId().equals(id)) {
System.out.println(student);
return;
}
}
System.out.println("找不到学生");
}
private void manageTeachers(Scanner scanner) {
// 类似于 manageStudents 方法
}
private void manageCourses(Scanner scanner) {
// 类似于 manageStudents 方法
}
private void manageClassrooms(Scanner scanner) {
// 类似于 manageStudents 方法
}
private void manageSchedules(Scanner scanner) {
// 类似于 manageStudents 方法
}
private void manageScores(Scanner scanner) {
// 类似于 manageStudents 方法
}
}
class Student {
private String name;
private int age;
private String gender;
private String id;
public Student(String name, int age, String gender, String id) {
this.name = name;
this.age = age;
this.gender = gender;
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
@Override
public String toString() {
return "Student{" +
"name='" + name + '\'' +
", age=" + age +
", gender='" + gender + '\'' +
", id='" + id + '\'' +
'}';
}
}
// 类似于 Student 类,定义 Teacher、Course、Classroom、Schedule 和 Score 类
```
这只是一个简单的示例,实际的教室管理系统可能需要更多的功能和更复杂的实现。
阅读全文