学生成绩管理系统java
时间: 2023-07-09 19:08:13 浏览: 39
学生成绩管理系统是一个典型的信息管理系统,用于管理学生的基本信息、课程信息和成绩信息。Java是一种非常流行的编程语言,可以用来开发这样的系统。下面是一个简单的学生成绩管理系统的Java实现。
1. 学生类
```
public 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;
}
}
```
2. 成绩类
```
public class Score {
private Student student; // 学生
private String course; // 课程名称
private int score; // 成绩
public Score(Student student, String course, int score) {
this.student = student;
this.course = course;
this.score = score;
}
public Student getStudent() {
return student;
}
public void setStudent(Student student) {
this.student = student;
}
public String getCourse() {
return course;
}
public void setCourse(String course) {
this.course = course;
}
public int getScore() {
return score;
}
public void setScore(int score) {
this.score = score;
}
}
```
3. 学生成绩管理类
```
import java.util.ArrayList;
import java.util.List;
public class StudentScoreManager {
private List<Student> students; // 学生列表
private List<Score> scores; // 成绩列表
public StudentScoreManager() {
students = new ArrayList<Student>();
scores = new ArrayList<Score>();
}
// 添加学生
public void addStudent(Student student) {
students.add(student);
}
// 添加成绩
public void addScore(Score score) {
scores.add(score);
}
// 根据学号查询学生
public Student searchStudentById(String id) {
for (Student student : students) {
if (student.getId().equals(id)) {
return student;
}
}
return null;
}
// 根据学号查询成绩
public List<Score> searchScoreById(String id) {
List<Score> result = new ArrayList<Score>();
for (Score score : scores) {
if (score.getStudent().getId().equals(id)) {
result.add(score);
}
}
return result;
}
}
```
这个学生成绩管理系统的实现只是一个简单的示例,可能还需要添加其他功能,比如修改学生信息、编辑成绩等等。但是,这个示例可以帮助你理解如何使用Java来开发类似的信息管理系统。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![doc](https://img-home.csdnimg.cn/images/20210720083327.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)