第1题
类包含关系,文件读写,字符串,排序.
题干
在测试类中读取A6stu.txt、A6cla.txt文件,分析文件中数据,根据classID进行关联,完成以下需求
需求1:
根据两个文件中的数据,分别创建班级类和学生类.
创建类的时候要求能体现出一个班级包含多个学生.
需求2:
把两个文件中的数据读取出来,把每个班级的信息解析出来封装成班级对象,把班级对象添加到班级集合中.
班级信息包括该班级的 班级编号,讲师,助理讲师,辅导员,和班级的所有学生.
需求3:
把平均年龄最大的班级的 班级编号,班级名称,讲师,助理样式,辅导员,平均年龄都打印出来.
需求4:
4.1把数学平均成绩最小的班级的 班级编号,班级名字以及成绩打印出来.
4.2把数学成绩不及格人数最多的班级编号,班级名字以及不及格人数都打印出来
4.3统计各班未成年人的人数,把这个人数以及对应班级的名字打印出来.
需求5:
把每个班级的学生都按照年龄从小到大的顺序排序,如果发现有年龄相同的,就按照数学成绩从小到大排序.
需求6:
把需求5 中排好序的各班级学生分别写入到不同的文件中.文件名为对应班级的班级编号.txt.
附录:
自行创建对应的文件,把以下数据拷贝到文件中.
A6cla.txt
<classes classID="C_01" classname="Java1班" teacher="栾博" assistant="武钊" instructor="张雨" /> <classes classID="C_02" classname="Java2班" teacher="梁桐" assistant="肖威" instructor="马森" /> <classes classID="C_03" classname="Java3班" teacher="谭仁龙" assistant="丁卫婵" instructor="章颖" /> <classes classID="C_04" classname="Java4班" teacher="刘悦" assistant="庞能" instructor="鲍倩" />
A6stu.txt
<student number="S_001" name="陈威" age="25" gender="男" math="80" classID="C_02" /> <student number="S_002" name="石有男" age="18" gender="男" math="81" classID="C_03" /> <student number="S_003" name="王林清" age="22" gender="男" math="82" classID="C_04" /> <student number="S_004" name="彭晓凯" age="19" gender="男" math="83" classID="C_01" /> <student number="S_005" name="贾相佳" age="19" gender="女" math="84" classID="C_01" /> <student number="S_006" name="徐佳文" age="19" gender="女" math="85" classID="C_02" /> <student number="S_007" name="胡苏凡" age="19" gender="女" math="86" classID="C_04" /> <student number="S_008" name="尹文芳" age="19" gender="女" math="87" classID="C_03" /> <student number="S_009" name="刘浩灿" age="19" gender="女" math="88" classID="C_03" /> <student number="S_010" name="连若伦" age="16" gender="女" math="89" classID="C_03" /> <student number="S_011" name="刘发" age="20" gender="女" math="90" classID="C_02" /> <student number="S_012" name="侯学帅" age="19" gender="男" math="60" classID="C_03" /> <student number="S_013" name="李国泰" age="17" gender="男" math="60" classID="C_03" /> <student number="S_014" name="王萌秀" age="18" gender="男" math="66" classID="C_03" /> <student number="S_015" name="王彦英" age="18" gender="男" math="40" classID="C_04" /> <student number="S_016" name="任豪" age="19" gender="男" math="50" classID="C_02" /> <student number="S_017" name="谢宇震" age="20" gender="男" math="20" classID="C_04" /> <student number="S_018" name="黄闯" age="19" gender="男" math="95" classID="C_03" /> <student number="S_019" name="刘亚旭" age="18" gender="男" math="30" classID="C_03" /> <student number="S_020" name="冉广琪" age="20" gender="男" math="87" classID="C_02" /> <student number="S_021" name="林金卓" age="19" gender="男" math="66" classID="C_01" /> <student number="S_022" name="孙景敏" age="19" gender="女" math="56" classID="C_01" /> <student number="S_023" name="张浩烨" age="18" gender="女" math="45" classID="C_01" /> <student number="S_024" name="杨珍淇" age="18" gender="男" math="99" classID="C_04" /> <student number="S_025" name="杨立飞" age="19" gender="男" math="100" classID="C_01" /> <student number="S_026" name="谢晋涵" age="19" gender="女" math="33" classID="C_01" /> <student number="S_027" name="瞿文悦" age="18" gender="男" math="44" classID="C_04" /> <student number="S_028" name="王佳鹏" age="18" gender="女" math="55" classID="C_04" /> <student number="S_029" name="杨亚俊" age="18" gender="女" math="50" classID="C_02" /> <student number="S_030" name="张明" age="20" gender="女" math="30" classID="C_02" /> <student number="S_031" name="郑福芳" age="20" gender="男" math="88" classID="C_04" /> <student number="S_032" name="刘江然" age="19" gender="男" math="87" classID="C_02" /> <student number="S_033" name="王琦泽" age="18" gender="女" math="80" classID="C_04" /> <student number="S_034" name="苏品尘" age="21" gender="男" math="80" classID="C_04" /> <student number="S_035" name="匡莹" age="19" gender="男" math="80" classID="C_03" /> <student number="S_036" name="王福涵" age="20" gender="女" math="80" classID="C_01" /> <student number="S_037" name="范子哲" age="18" gender="女" math="80" classID="C_01" /> <student number="S_038" name="王椿标" age="20" gender="女" math="80" classID="C_03" /> <student number="S_039" name="罗强" age="17" gender="女" math="32" classID="C_04" /> <student number="S_040" name="刘存龙" age="19" gender="男" math="44" classID="C_04" /> <student number="S_041" name="高孜薇" age="19" gender="女" math="56" classID="C_01" /> <student number="S_042" name="王庆怡" age="18" gender="男" math="80" classID="C_01" /> <student number="S_043" name="邓桧" age="17" gender="男" math="80" classID="C_01" /> <student number="S_044" name="李晓赞" age="17" gender="女" math="12" classID="C_03" /> <student number="S_045" name="齐若华" age="17" gender="女" math="80" classID="C_04" /> <student number="S_046" name="庞生" age="19" gender="女" math="1" classID="C_04" /> <student number="S_047" name="许宇宇" age="18" gender="女" math="80" classID="C_02" /> <student number="S_048" name="怀玉睿" age="21" gender="女" math="80" classID="C_01" /> <student number="S_049" name="郭一玮" age="19" gender="女" math="65" classID="C_02" /> <student number="S_050" name="乔森" age="17" gender="女" math="80" classID="C_02" /> <student number="S_051" name="刘浩康" age="18" gender="女" math="80" classID="C_03" /> <student number="S_052" name="冯永楠" age="17" gender="男" math="47" classID="C_03" /> <student number="S_053" name="洪锦波" age="18" gender="男" math="90" classID="C_02" /> <student number="S_054" name="刘志" age="19" gender="男" math="80" classID="C_03" /> <student number="S_055" name="谌笑" age="17" gender="男" math="80" classID="C_01" /> <student number="S_056" name="唐伯" age="18" gender="男" math="80" classID="C_01" /> <student number="S_057" name="杨嘉双" age="18" gender="男" math="80" classID="C_04" /> <student number="S_058" name="曹文刚" age="24" gender="女" math="51" classID="C_03" /> <student number="S_059" name="罗昱超" age="14" gender="女" math="52" classID="C_04" /> <student number="S_060" name="宋逸峰" age="18" gender="女" math="53" classID="C_01" /> <student number="S_061" name="李梓梁" age="18" gender="男" math="54" classID="C_01" /> <student number="S_062" name="王雪希" age="14" gender="男" math="55" classID="C_01" /> <student number="S_063" name="袁奕权" age="16" gender="女" math="56" classID="C_02" /> <student number="S_064" name="芦玥崴" age="17" gender="女" math="57" classID="C_03" /> <student number="S_065" name="刘阿林" age="15" gender="女" math="58" classID="C_01" />