实现 Schoolsystem类
- Schoolsystem( Integer big, Integer medium, Integer small)l初始化Schoolsystem类,三个参数分别对应每种班级的剩余名额。
(2) bool addstudert( Integer stu ype)检查是否有 stutype对应的班级。 stutypet有三种类型:大,中,小,分别用数字1,2和3表示。一个学生只能在 stutype对应的班级中。如果没有剩余多的班级人数,请返回 false,否则将该学生录入班级井返回true
(3) Stringl parse( String input)解析输入字符串(格式见示列)返回字符串数组
(4) void printi()输出结果(格式见示例)
r'scholsystem, addstuden "adcstudert" addstudent addstudent']
[1,1,0],[1],[2],[3],[1]
输出
[null true, true, false, false]
解释
School System school System= rew Schoolsystem(1,1,0);/初始化有1个大班名额,1个中班名额,0个小班名额
schoolsystem. addstudent(1)∥返回true,因为有1个剩余的大班名额
school System. addstudent(2);/返回tue,因为有1个剩余的中班名额
schodsyster. addstudent(3)返回 false,因为没有剩余的小班名额
schod System. addstudent(1)返回 false,因为没有剩余的大班名额,唯一1个大班名额经被占据了
需要实现的接口及代码主体参考
/报名入学接口
interface Isignupf
打印輸出结果
public vold printo;
∥检查是否有 stuType对应的班级名额
∥如果没有剩余名额,请返回 false,否则学生将报名进入该班级并返回true
public boolean adcstudert (int stutype),
解析命令行输入的参数(格式),如文摧述
public static Iparams parse throws Exception
interface Params
∥获取大班名额
public int geteigo)
∥获取中班名额
public int getmedium
获取小班名额
public int getsma
∥获取入学序列,例如[1223]表示依次报名入学一名大班学生,中班学生,中班学生,小班学生