//源代码
import java.util.Scanner;
public class RoomManagement {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
RoomInformation r1 = new RoomInformation("9#401", "20214001", "20214002", "20214003", "20214004", 0);
RoomInformation r2 = new RoomInformation("9#402", "", "", "", "", 0);
RoomInformation r3 = new RoomInformation("9#403", "", "", "", "", 0);
RoomInformation r4 = new RoomInformation("9#404", "", "", "", "", 0);
RoomInformation r5 = new RoomInformation("9#405", "", "20214011", "20214012", "20214013", 0);
RoomInformation r6 = new RoomInformation("9#406", "20214021", "", "20214022", "20214023", 0);
RoomInformation r7 = new RoomInformation("9#407", "20214031", "20214032", "", "20214033", 0);
RoomInformation r8 = new RoomInformation("9#408", "20214041", "20214042", "20214043", "20214044", 0);
RoomInformation r9 = new RoomInformation("9#409", "20214051", "20214052", "20214053", "20214054", 0);
RoomInformation r10 = new RoomInformation("9#410", "20214061", "20214062", "20214063", "20214064", 0);
rf[1] = r1;
rf[2] = r2;
rf[3] = r3;
rf[4] = r4;
rf[5] = r5;
rf[6] = r6;
rf[7] = r7;
rf[8] = r8;
rf[9] = r9;
rf[10] = r10;
menu1();
}
static RoomInformation rf[] = new RoomInformation[1010];
static int cnt = 10;
public static void menu() {
System.out.println("***********************************************************");
System.out.println(" 石家庄铁道大学");
System.out.println(" 学生公寓管理系统v2022");
System.out.println("***********************************************************");
System.out.println(" 1、宿舍查询");
System.out.println(" 2、安排新宿舍");
System.out.println(" 3、调整宿舍");
System.out.println(" 4、宿舍卫生评价");
System.out.println(" 5、卫生检查情况查询");
System.out.println("**********************************************************");
}
public static void menu1() {
int n = 0;
while (n != 5) {
Scanner sc = new Scanner(System.in);
menu();
n = sc.nextInt();
if (n == 1)
chaxun();
else if (n == 2)
anpai();
else if (n == 3)
tiaozheng();
else if (n == 4)
weishengpingjia();
else if (n == 5)
weishengchaxun();
else {
System.out.println("该选项不存在");
menu();
}
}
}
public static void chaxun() {
System.out.print("***********************************************************\n"
+ " 石家庄铁道大学\r\n"
+ " 学生公寓管理系统v2022\r\n"
+ "***********************************************************\r\n"
+ "");
for (int i = 1; i <= cnt; i++) {
int no_cnt = 0;//统计人数
System.out.print(i + "、" + rf[i].getRoomno() + "\t");
if (rf[i].getStunno1() != "")
no_cnt++;
if (rf[i].getStunno2() != "")
no_cnt++;
if (rf[i].getStunno3() != "")
no_cnt++;
if (rf[i].getStunno4() != "")
no_cnt++;
if (no_cnt == 4) {
System.out.print(no_cnt + "人" + "\t");
System.out.print("已满\n");
}
else if (no_cnt == 3) {
System.out.print(no_cnt + "人" + "\t");
System.out.print("空1人\n");
}
else if (no_cnt == 2) {
System.out.print(no_cnt + "人" + "\t");
System.out.print("空2人\n");
}
else if (no_cnt == 1) {
System.out.print(no_cnt + "人" + "\t");
System.out.print("空3人\n");
}
else if (no_cnt == 0) {
System.out.print(no_cnt + "人" + "\t");
System.out.print("空宿舍\n");
}
}
}
public static int anpaipanduan(String no0) {
if (no0.equals("END")) {
return 3;
}
for(int i = 1; i <= cnt; i++) {
if (no0.equals(rf[i].getStunno1()) || no0.equals(rf[i].getStunno2()) || no0.equals(rf[i].getStunno3()) || no0.equals(rf[i].getStunno4())) {
System.out.print("该学生已分配宿舍\n");
return 2;
}
}
return 1;
}
public static void anpaijiemian() {
Scanner sc = new Scanner(System.in);
System.out.print("***********************************************************\n"
+ " 石家庄铁道大学\r\n"
+ " 学生公寓管理系统v2022\r\n"
+ " 安排新宿舍\r\n"
+ "***********************************************************\r\n"
+ " 新宿舍号:\r\n"
+ "");
System.out.print("1、床位1:");
String no1 = sc.next();
if (anpaipanduan(no1) == 2) {
no1 = sc.next();
}
else if (anpaipanduan(no1) == 3) {
cnt ++;
menu();
}
System.out.print("\n");
System.out.print("2、床位2:");
String no2 = sc.next();
if (anpaipanduan(no2) == 2) {
no2 = sc.next();
}
else if (anpaipanduan(no2) == 3) {
cnt ++;
menu();
}
System.out.print("\n");
System.out.print("3、床位3:");
String no3 = sc.next();
if (anpaipanduan(no3) == 2) {
no3 = sc.next();
}
else if (anpaipanduan(no3) == 3) {
cnt ++;
menu();
}
System.out.print("\n");
System.out.print("4、床位4:");
String no4 = sc.next();
System.out.print("***********************************************************\n");
if (anpaipanduan(no4) == 2) {
no4 = sc.next();
}
else if (anpaipanduan(no4) == 3 || anpaipanduan(no4) == 1) {
System.out.print("\n");
System.out.print("提示该宿舍已满\n");
cnt ++;
menu();
}
}
public static void anpai() {
Scanner sc = new Scanner(System.in);
System.out.print("***********************************************************\n"
+ " 石家庄铁道大学\r\n"
+ " 学生公寓管理系统v2022\r\n"
+ " 安排新宿舍\r\n"
+ "***********************************************************\r\n"
+ "");
System.out.print(" 空宿舍详细信息列表\n");
for (int i = 1; i <= cnt; i++) {
if (rf[i].getStunno1() == "" && rf[i].getStunno2() == "" && rf[i].getStunno3() == "" && rf[i].getStunno4() == "") {
System.out.print(i + "、" + rf[i].getRoomno() + "\t\t" + "0人\t空宿舍\n");
}
}
System.out.print(" 请输入新宿舍号:");
String new_roomno = sc.next();
System.out.print("***********************************************************\n");
for (int i = 1; i <= cnt; i++) {
if(new_roomno.equals(rf[i].getRoomno())) {
if (rf[i].getStunno1() == "" && rf[i].getStunno2() == "" && rf[i].getStunno3() == "" && rf[i].getStunno4() == "") {
anpaijiemian();
}
else {
System.out.print("该宿舍不是空宿舍,无法安排新生\n");
}
}
}
}
public static void tiaozhengjiemian() {
Scanner sc = new Scanner(System.in);
System.out.print("***********************************************************\n"
+ " 石家庄铁道大学\r\n"
+ " 学生公寓管理系统v2022\r\n"
+ " 调整宿舍\r\n"
+ "***********************************************************\r\n"
+ " 有空床位宿舍详细信息列表\r\n"
+ "");
for (int i = 1; i <= cnt; i++) {
int no_cnt = 0;//统计人数
System.out.print(i + "、" + rf[i].getRoomno() + "\t");
if (rf[i].getStunno1() != "")
no_cnt++;
if (rf[i].getStunno2() != "")
no_cnt++;
if (rf[i].getStunno3() != "")
no_cnt++;
if (rf[i].getStunno4() != "")
no_cnt++;
if (no_cnt == 3) {
System.out.print(no_cnt + "人" + "\t");
System.out.print("空1人\n");
}
else if (no_cnt == 2) {
System.out.print(no_cnt + "人" + "\t");
System.out.print("空2人\n");
}
else if (no_cnt == 1) {
System.out.print(no_cnt + "人" + "\t");
System.out.print("空3人\n");
}
}
System.out.print("请输入待调整宿舍号:");
}
public static void tiaozhengjiemian2(String roomno) {
System.out.print("***********************************************************\n"
+ "石家庄铁道大学\r\n"
+ "学生公寓管理系统v2022\r\n"
+ "调整宿舍\r\n"
+ "***********************************************************\r\n"
+ "待调整宿舍号:"
+ roomno
+ "");
}
public static void tiaozheng() {
Scanner sc = new Scanner(System.in);
tiaozhengjiemian();
String new_roomno = sc.next();
System.out.print("***********************************************************\n");
for (int i = 1; i <= cnt; i++) {
if (new_roomno.equals(rf[i].getRoomno())) {
if (rf[i].getStunno1() == "" || rf[i].getStunno2() == "" || rf[i].getStunno3() == "" || rf[i].getStunno4() == "") {
tiaozhengjiemian2(new_roomno);
System.out.print("1、床位1:");
System.out.print(rf[i].getStunno1());
System.out.print("2、床位2:");
System.out.print(rf[i].getStunno2());
System.out.print("3、床位3:");
System.out.print(rf[i].getStunno3());
System.out.print("4、床位4:");
String stuno = sc.next();
if (anpaipanduan(stuno) == 3) {
menu();
}
else if (anpaipanduan(stuno) == 2) {
tiaozhengjiemian2(new_roomno);
}
else {
System.out.print("提示该宿舍已满");
menu();
}
}
else if (rf[i].getStunno1() != "" && rf[i].getStunno2() != "" && rf[i].getStunno3() != "" && rf[i].getStunno4() != "") {
System.out.print("该宿舍没有空床位,无法调整");
}
}
}
}
public static void wsjm() {
System.out.print("***********************************************************\n"
+ "石家庄铁道大学\r\n"
+ "学生公寓管理系统v2022\r\n"
+ "宿舍卫生\r\n"
+ "***********************************************************\r\n"
+ "");
System.out.print("请输入待评价宿舍号:");
}
public static void weishengpingjia() {
Scanner sc = new Scanner(System.in);
System.out.print("***********************************************************\n"
+ "石家庄铁道大学\r\n"
+ "学生公寓管理系统v2022\r\n"
+ "宿舍卫生\r\n"
+ "***********************************************************\r\n"
+ "");
System.out.print("请输入待评价宿舍号:");
String roomno = sc.next();
for (int i = 1; i <= cnt; i++) {
if (roomno.equals(rf[i].getRoomno())) {
if (rf[i].getStunno1() == "" && rf[i].getStunno2() == "" && rf[i].getStunno3() == "" && rf[i].getStunno4() == "") {
System.out.print("该宿舍为空宿舍");
weishengpingjia();
}
else {
System.out.print("***********************************************************\n"
+ "石家庄铁道大学\r\n"
+ "学生公寓管理系统v2022\r\n"
+ "宿舍卫生评价\r\n"
+ "***********************************************************\r\n"
+ "宿舍号:\r\n"
+ "");
System.out.print(roomno);
System.out.print("1、床位1:");
System.out.print(rf[i].getStunno1());
System.out.print("2、床位2:");
System.out.print(rf[i].getStunno2());
System.out.print("3、床位3:");
System.out.print(rf[i].getStunno3());
System.out.print("4、床位4:");
System.out.print(rf[i].getStunno4());
System.out.print("输入宿舍卫生评价分数:");
int wsscore = 0;
while (true) {
wsscore = sc.nextInt();
if (wsscore >=0 && wsscore <= 100) {
break;
}
else {
System.out.print("输入错误");
}
}
System.out.print("***********************************************************\n");
}
}
}
System.out.print("***********************************************************\n");
}
public static void weishengchaxun() {
System.out.print("***********************************************************\n"
+ "石家庄铁道大学\r\n"
+ "学生公寓管理系统v2022\r\n"
+ "卫生检查情况查询\r\n"
+ "***********************************************************\r\n"
+ "宿舍卫生检查情况信息\r\n"
+ "");
for (int i = 1; i <= cnt; i++) {
System.out.print(rf[i].getRoomno() + "\t" + rf[i].getHygienescore());
if (rf[i].getHygienescore() < 60)
System.out.print("不合格");
else if (rf[i].getHygienescore() >= 60 && rf[i].getHygienescore() < 80)
System.out.print("合格");
else if (rf[i].getHygienescore() >= 80 && rf[i].getHygienescore() < 90)
System.out.print("良好");
else if (rf[i].getHygienescore() >= 90)
System.out.print("优秀");
}
}
}
class RoomInformation {
private String roomno;// 8位 eg:9#502
private String stunno1, stunno2, stunno3, stunno4;
// 8位 空表示无数值,代表空余床位,
// 都空表示空宿舍
private int hygienescore;// 0-100 卫生标准分
// <60 不合格;>=60 合格;>=80 良好;>=90 优秀
public String getRoomno() {
return roomno;
}
public void setRoomno(String roomno) {
this.roomno = roomno;
}
public String getStunno1() {
return stunno1;
}
public void setStunno1(String stunno1) {
this.stunno1 = stunno1;
}
public String getStunno2() {
return stunno2;
}
public void setStunno2(String stunno2) {
this.stunno2 = stunno2;
}
public String getStunno3() {
return stunno3;
}
public void setStunno3(String stunno3) {
this.stunno3 = stunno3;
}
public String getStunno4() {
return stunno4;
}
public void setStunno4(String stunno4) {
this.stunno4 = stunno4;
}
public int getHygienescore() {
return hygienescore;
}
public void setHygienescore(int hygienescore) {
this.hygienescore = hygienescore;
}
public RoomInformation(String roomno, String stunno1, String stunno2, String stunno3, String stunno4,
int hygienescore) {
this.roomno = roomno;
this.stunno1 = stunno1;
this.stunno2 = stunno2;
this.stunno3 = stunno3;
this.stunno4 = stunno4;
this.hygienescore = hygienescore;
}
public RoomInformation(RoomInformation r0) {
this.roomno = r0.roomno;
this.stunno1 = r0.stunno1;
this.stunno2 = r0.stunno2;
this.stunno3 = r0.stunno3;
this.stunno4 = r0.stunno4;
this.hygienescore = r0.hygienescore;
}
}