代码拉取完成,页面将自动刷新
package week13;
import java.util.ArrayList;
import java.util.Random;
import java.util.Scanner;
public class StudentManager {
Scanner sc = new Scanner(System.in);
ArrayList<StudentClass> studentClasses = new ArrayList<StudentClass>();
Random rd = new Random();
public void exportGrade(StudentClass studentClass) {
System.out.println("导出成绩");
System.out.println("=====================");
ArrayList<Student> students = studentClass.getStudents();
for (int i = 0; i < students.size(); i++) {
System.out.println(students.get(i).getName() + " " + students.get(i).getMarks());
}
}
public Object[] randomChooseStudent(int classId) {
StudentClass studentClass = studentClasses.get(classId - 1);
int studentId = rd.nextInt(studentClass.getStudents().size());
Student student = studentClass.getStudents().get(studentId);
return new Object[]{student.getName(), student.getId()};
}
public void studentGradeManagement(StudentClass studentClass) {
}
public void studentAttendanceRecord(StudentClass studentClass) {
}
public void addStudent(String name, int id, int classId) {
StudentClass studentClass = studentClasses.get(classId - 1);
studentClass.getStudents().add(new Student(name, id));
}
public Object[][] listStudents(Integer classId) {
StudentClass studentClass = studentClasses.get(classId - 1);
Object[][] students = new Object[studentClass.getStudents().size()][2];
for (int i = 0; i < studentClass.getStudents().size(); i++) {
students[i][1] = studentClass.getStudents().get(i).getId();
students[i][0] = studentClass.getStudents().get(i).getName();
}
return students;
}
public Object[][] listGroups(int classId) {
StudentClass studentClass = studentClasses.get(classId - 1);
Object[][] groups = new Object[studentClass.getGroups().size()][5];
for (int i = 0; i < studentClass.getGroups().size(); i++) {
groups[i][0] = "小组" + (i + 1);
groups[i][1] = studentClass.getGroups().get(i).getStu1().getName();
groups[i][2] = studentClass.getGroups().get(i).getStu1().getId();
groups[i][3] = studentClass.getGroups().get(i).getStu2().getName();
groups[i][4] = studentClass.getGroups().get(i).getStu2().getId();
}
return groups;
}
public void addNewGroup(String name1, int id1, String name2, int id2, int classId) {
Student student1 = new Student(name1, id1);
Student student2 = new Student(name2, id2);
StudentClass studentClass = studentClasses.get(classId - 1);
studentClass.getStudents().add(student1);
studentClass.getStudents().add(student2);
studentClass.getGroups().add(new Group(student1, student2));
}
//班级管理
public void addNewClass() {
studentClasses.add(new StudentClass());
}
public Object[][] listClasses() {
Object[][] classes = new Object[studentClasses.size()][2];
for (int i = 0; i < studentClasses.size(); i++) {
classes[i][0] = "班级" + (i + 1);
classes[i][1] = studentClasses.get(i).getStudents().size();
}
return classes;
}
public String[] getAllClasses() {
studentClasses.add(new StudentClass());
String[] classes = new String[studentClasses.size()];
for (int i = 0; i < studentClasses.size(); i++) {
classes[i] = "班级" + (i + 1);
}
return classes;
}
public void recordGrade(int className, String name, int id, double grade) {
StudentClass studentClass = studentClasses.get(className - 1);
for (int i = 0; i < studentClass.getStudents().size(); i++) {
if (studentClass.getStudents().get(i).getId() == id&&studentClass.getStudents().get(i).getName().equals(name)) {
studentClass.getStudents().get(i).setMarks(grade);
break;
}
}
}
public Object[][] getGradesList(int classNum) {
StudentClass studentClass = studentClasses.get(classNum - 1);
Object[][] grades = new Object[studentClass.getStudents().size()][3];
for (int i = 0; i < studentClass.getStudents().size(); i++) {
grades[i][0] = studentClass.getStudents().get(i).getId();
grades[i][1] = studentClass.getStudents().get(i).getName();
grades[i][2] = studentClass.getStudents().get(i).getMarks();
}
return grades;
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。