代码拉取完成,页面将自动刷新
同步操作将从 sheng7963/刘昇-202110098196 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
package version;
import java.util.ArrayList;
import java.util.Scanner;
public class SchoolSystem implements ISignUp //刘昇爸爸是陈淑创
{
//合并分支
Integer big;
Integer medium;
Integer small;
SchoolSystem (Integer big, Integer medium, Integer small)
{
this.big=big;
this.medium=medium;
this.small=small;
}
public static void main(String[] args) throws Exception
{
IParams params = ISignUp.parse();
SchoolSystem sc = new SchoolSystem (params.getBig(), params.getMedium(),params.getSmall());
ArrayList<Integer> plan =params.getPlanSignUp();
ArrayList <Boolean>whether=new ArrayList();
for (int i = 0; i < plan.size(); i++)
{
whether.add( sc.addStudent (plan.get(i)));
}
sc. print(whether);
}
public void print (ArrayList<Boolean> whether)
{
System.out.println(whether);
}
public boolean addStudent(int stuType)
{
if((stuType==1)&&(big!=0))
{
big--;
return true;
}
else if(stuType==2&&medium!=0)
{
medium--;
return true;
}
else if(stuType==3&&small!=0)
{
small--;
return true;
}
else
return false;
}
}
//报名入学接口
interface ISignUp
{
// 打印输出结果
public void print(ArrayList<Boolean> plan);
// 检查是否有 stuType对应的班级名额
// 如果没有剩余名额,请返回 false ,否则学生将报名进入该班级并返回 true
public boolean addStudent (int stuType);
// 解析命令行输入的参数(格式),如文档描述
public static IParams parse() throws Exception
{
Scanner sc=new Scanner(System.in);
System.out.print("请输入每种班级的剩余名额:");
Integer big=sc.nextInt();
Integer medium=sc.nextInt();
Integer small=sc.nextInt();
ArrayList <Integer> list=new ArrayList();
System.out.print("请输入需要进入的班级:");
//输入报名班级次序,4次
for(int i=1;i<5;i++)
{
list.add(sc.nextInt());
}
//SchoolSystem scs=new SchoolSystem(big,medium,small);
return new IParams()
{
public int getBig()
{
return big;
}
public int getMedium()
{
return medium;
}
public int getSmall()
{
return small;
}
public ArrayList<Integer> getPlanSignUp()
{
return list;
}
};
};
}
interface IParams
{
// 获取大班名额
public int getBig();
// 获取中班名额
public int getMedium();
// 获取小班名额
public int getSmall();
// 获取入学序列,例如 [1 2 2 3] 表示 依次报名入学一名大班学生,中班学生,中班学生,小班学生
public ArrayList<Integer> getPlanSignUp ();
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。