package test;
import java.util.Scanner;
public class RoomManagement {
static int sum=0;
static RoomInformation a[]=new RoomInformation[10];
public static void firstInput()
{
sum=10;
a[0]=new RoomInformation("9#101","00000000","00000001","00000002","00000003",0);
a[1]=new RoomInformation("9#102","00000004","00000005","00000006","00000007",0);
a[2]=new RoomInformation("9#103","00000008","00000009","0000010","",0);
a[3]=new RoomInformation("9#104","00000011","00000012","","",0);
a[4]=new RoomInformation("9#105","00000013","","","",0);
a[5]=new RoomInformation("9#106","00000014","00000015","00000016","00000017",0);
a[6]=new RoomInformation("9#107","","","","",0);
a[7]=new RoomInformation("9#108","","","","",0);
a[8]=new RoomInformation("9#109","","","","",0);
a[9]=new RoomInformation("9#110","00000018","","","",0);
}
public static int mainFrame()//主界面
{
Scanner in=new Scanner(System.in);
System.out.println("***********************************************************\n"+
"石家庄铁道大学\n"+
"学生公寓管理系统v2022\n"+
"***********************************************************\n"+
"1、宿舍查询\n"+
"2、安排新宿舍\n"+
"3、调整宿舍\n"+
"4、宿舍卫生评价\n"+
"5、卫生检查情况查询\n"+
"**********************************************************");
int ch;
System.out.println("请选择:");
ch = in.nextInt();
return ch;
}
public static int renshu(String roomno)//查询宿舍人数
{
Scanner in=new Scanner(System.in);
int i,j,m=0;
for(i=0;i<sum;i++)
{
if(a[i].getroomno().compareTo(roomno)==0)
{
j=i;
if(a[j].getstunno1()=="")
{
}
else
{
m++;
}
if(a[j].getstunno2()=="")
{
}
else
{
m++;
}
if(a[j].getstunno3()=="")
{
}
else
{
m++;
}
if(a[j].getstunno4()=="")
{
}
else
{
m++;
}
}
}
return m;
}
public static String zhuangtai(String roomno)//宿舍状态
{
Scanner in=new Scanner(System.in);
int nn;
String mm = null;
nn=renshu(roomno);
if(nn==4)
{
mm="已满";
}
if(nn==3)
{
mm="空1人";
}
if(nn==2)
{
mm="空2人";
}
if(nn==1)
{
mm="空3人";
}
if(nn==0)
{
mm="空宿舍";
}
return mm;
}
public static void chaxun()//1、宿舍查询
{
int i;
Scanner in=new Scanner(System.in);
System.out.println("***********************************************************\n"+
"石家庄铁道大学\n"+
"学生公寓管理系统v2022\n"+
"***********************************************************\n"+
"宿舍详细信息列表\n");
for(i=0;i<sum;i++)
{
int m=i+1;
System.out.print(m);
System.out.println('、'+a[i].getroomno()+" "+renshu(a[i].getroomno())+"人 "+zhuangtai(a[i].getroomno())+"\n");
}
System.out.println(" …………………….\n"+
"**********************************************************");
}
public static void anpai()//2、安排新宿舍
{
int i,ii;
String cc;
Scanner in=new Scanner(System.in);
System.out.println("***********************************************************\n"+
"石家庄铁道大学\n"+
"学生公寓管理系统v2022\n"+
"安排新宿舍\n"+
"***********************************************************\n"+
"空宿舍详细信息列表"
);
for(i=0;i<sum;i++)
{
int m=i+1;
System.out.print(m);
System.out.println('、'+a[i].getroomno()+" "+renshu(a[i].getroomno())+"人 "+zhuangtai(a[i].getroomno())+"\n");
}
System.out.println(" …………………….\n"+
" 请输入新宿舍号:\n"+
"**********************************************************");
cc=in.next();
if(zhuangtai(cc)=="空宿舍")
{
System.out.println("***********************************************************\n"+
"石家庄铁道大学\n"+
"学生公寓管理系统v2022\n"+
"安排新宿舍\n"+
"***********************************************************\n"+
"新宿舍号:\n");
for(i=0;i<sum;i++)
{
if(a[i].getroomno().compareTo(cc)==0)
{
ii=i;
String b="床位";
System.out.print('1');
System.out.println('、'+b+'1'+':');
System.out.print('2');
System.out.println('、'+b+'2'+':');
System.out.print('3');
System.out.println('、'+b+'3'+':');
System.out.print('4');
System.out.println('、'+b+'4'+':');
System.out.println(" **********************************************************");
String bn;
bn=in.next();
a[ii].setstunno1(bn);
if(a[ii].getstunno1().equals("END"))
{
mainFrame();
}
bn=in.next();
a[ii].setstunno2(bn);
if(a[ii].getstunno2().equals("END"))
{
mainFrame();
}
bn=in.next();
a[ii].setstunno3(bn);
if(a[ii].getstunno3().equals("END"))
{
mainFrame();
}
bn=in.next();
a[ii].setstunno4(bn);
System.out.println("提示该宿舍已满");
}
}
}
else
{
System.out.println("该宿舍不是空宿舍,无法安排新生");
return;
}
}
public static void pingjia()//4、宿舍卫生评价
{
Scanner in=new Scanner(System.in);
}
public static void main(String[] args)
{
Scanner in=new Scanner(System.in);
int i;
firstInput();
i=mainFrame();
switch(i)
{
case 1:chaxun();break;
case 2:anpai();break;
default:
{
System.out.println("该选项不存在");
break;
}
}
}
}