|  |  | @ -9,8 +9,12 @@ import java.util.HashMap; | 
			
		
	
		
		
			
				
					
					|  |  |  |  * 对Student类的操作的上层封装,有较为多的操作 |  |  |  |  * 对Student类的操作的上层封装,有较为多的操作 | 
			
		
	
		
		
			
				
					
					|  |  |  |  */ |  |  |  |  */ | 
			
		
	
		
		
			
				
					
					|  |  |  | public class StudentManager { |  |  |  | public class StudentManager { | 
			
		
	
		
		
			
				
					
					|  |  |  |     private final ArrayList<Student> students = new ArrayList<>(); |  |  |  |     private final ArrayList<Student> students; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |     private final ManagerTool managerTool = new ManagerTool(students); |  |  |  |     private final ManagerTool managerTool = new ManagerTool(); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     public StudentManager() { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         this.students = managerTool.getStudentList(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     /** |  |  |  |     /** | 
			
		
	
		
		
			
				
					
					|  |  |  |      * 增添学生。输入的字符串格式应为 [id] [name] ...[subjectName,score] |  |  |  |      * 增添学生。输入的字符串格式应为 [id] [name] ...[subjectName,score] | 
			
		
	
	
		
		
			
				
					|  |  | @ -34,6 +38,23 @@ public class StudentManager { | 
			
		
	
		
		
			
				
					
					|  |  |  |         managerTool.addStudent(id, name, score); |  |  |  |         managerTool.addStudent(id, name, score); | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     /** | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      * 删除一个学生(按ID) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      * | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      * @param id 学生id,long格式 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      */ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     protected void removeStudent(long id) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         managerTool.removeStudent(id); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     /** | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      * 删除一个学生(按姓名) | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      * | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      * @param name 学生姓名,long格式 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      */ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     protected void removeStudent(String name) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         managerTool.removeStudent(name); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     // 要是Java能像go语言那样返回两个返回值就好了...
 |  |  |  |     // 要是Java能像go语言那样返回两个返回值就好了...
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     // 这样就能同时返回平均值和总值了...
 |  |  |  |     // 这样就能同时返回平均值和总值了...
 | 
			
		
	
	
		
		
			
				
					|  |  | @ -98,7 +119,8 @@ public class StudentManager { | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |     /** |  |  |  |     /** | 
			
		
	
		
		
			
				
					
					|  |  |  |      *  获取所有科目 |  |  |  |      * 获取所有科目 | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      * | 
			
		
	
		
		
			
				
					
					|  |  |  |      * @return 包含有科目名称的ArrayList |  |  |  |      * @return 包含有科目名称的ArrayList | 
			
		
	
		
		
			
				
					
					|  |  |  |      */ |  |  |  |      */ | 
			
		
	
		
		
			
				
					
					|  |  |  |     public ArrayList<String> getSubjects() { |  |  |  |     public ArrayList<String> getSubjects() { | 
			
		
	
	
		
		
			
				
					|  |  | @ -173,7 +195,7 @@ public class StudentManager { | 
			
		
	
		
		
			
				
					
					|  |  |  |      */ |  |  |  |      */ | 
			
		
	
		
		
			
				
					
					|  |  |  |     private String listScore(Student student) { |  |  |  |     private String listScore(Student student) { | 
			
		
	
		
		
			
				
					
					|  |  |  |         StringBuilder stringBuilder = new StringBuilder(); |  |  |  |         StringBuilder stringBuilder = new StringBuilder(); | 
			
		
	
		
		
			
				
					
					|  |  |  |         ArrayList<String> subjects = managerTool.getAllSubjects(); |  |  |  |         ArrayList<String> subjects = getSubjects(); | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         for (String subject : subjects) { |  |  |  |         for (String subject : subjects) { | 
			
		
	
		
		
			
				
					
					|  |  |  |             stringBuilder |  |  |  |             stringBuilder | 
			
		
	
	
		
		
			
				
					|  |  | @ -183,4 +205,43 @@ public class StudentManager { | 
			
		
	
		
		
			
				
					
					|  |  |  |         return stringBuilder.toString(); |  |  |  |         return stringBuilder.toString(); | 
			
		
	
		
		
			
				
					
					|  |  |  |     } |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     /** | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      * 列出所有科目的成绩信息,包括总分、平均分 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      * @return 信息字符串 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      */ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     public String listAllSubjectScore() { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         StringBuilder stringBuilder = new StringBuilder(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         ArrayList<String> subjects = getSubjects(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         for (String subject : subjects) { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |             stringBuilder | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     .append(subject).append(" | General Score: ") | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     .append(this.getSubjectScore(subject)).append(" | Avg Score: ") | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                     .append(this.getSubjectAvgScore(subject)).append('\n'); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         return stringBuilder.toString(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     /** | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      * 生成总的学生及科目成绩信息 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      * @return 信息字符串 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |      */ | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     public String generateAllInformation() { | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         StringBuilder stringBuilder = new StringBuilder(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         stringBuilder | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 .append("------------------------------------") | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 .append("      All Student Information       ") | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 .append("------------------------------------").append('\n') | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 .append(this.generateScoreTableByName()).append('\n') | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 .append("------------------------------------") | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 .append("       All Subject Information      ") | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 .append("------------------------------------").append('\n') | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |                 .append(this.listAllSubjectScore()); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         return stringBuilder.toString(); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |     } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  | } |  |  |  | } | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
	
		
		
			
				
					|  |  | 
 |