为什么考式没有达标?

我的得分是10.5分,程序实现了前两个功能,后面的功能都写了一半,在后面的程序中对循环中的一个条件判断

总是的不到正确的结果,最终着急了,当时就有点着急,慌乱了,最后也没有找出问题,当时静不下心来,仔细地看一看

总是在思考程序结构没有问题啊,怎么就的不到正确的结构呢,到结束后,仔细地从出错的地方看下来的时候,突然醒悟

在循环中开始的第一条语句就是判断,直接紧接着就是else{其他语句 return了},这就导致循环只进行了一次,最后我实在

想不通为什么,会出现这样的情况,导致在这里浪费了太多时间,将近一个多小时吧。到最后的几个功能当时是真的没有时间

完成了。

  这里面当然也有自己暑假学习方面的原因,开始的时候,学了一点知识,发现和c++的语法大体一样,也就到最后慢慢的不认真了

学完输入,输出之后,到条件语句,循环,这些与c++ 的一样,就放松了一段时间,直到临近开学的时候又学了一点,以为是没有问题的

。在学校考试的时候,我当时的感觉真的是认为及格是没有问题的,但是,但是,没有想到,毛线从细处断了,出现了问题之后,找问题的

时候只考虑了,结构的合理性,忽略了最基本的循环的判断。在考完后,回到宿舍,我就开始找出错的原因,补充了程序,最后程序的功能

也是全部都已完成。我放到下面:

复制代码
package XuShexinxi;

public class RoomInformation {
   private String roomhao,roomstu1,roomstu2,roomstu3,roomstu4;
   private int hygscore;
   public RoomInformation() {
          
   }
 public RoomInformation(String roomhao,String roomstu1,String roomstu2,String roomstu3,String roomstu4,int hygscore){
      this.roomhao=roomhao;
      this.roomstu1=roomstu1;
      this.roomstu2=roomstu2;
      this.roomstu3=roomstu3;
      this.roomstu4=roomstu4;
      this.hygscore=hygscore;
   }
 public void setRh(String roomhao) {
      this.roomhao=roomhao;
 }
 public String getRH() {
      return roomhao;
 }
 public void setRs1(String roomstu1) {
      this.roomstu1=roomstu1;
 }
 public String getRs1() {
      return roomstu1;
 }
 public void setRs2(String roomstu2) {
      this.roomstu2=roomstu2;
}
public String getRs2() {
      return roomstu2;
}
public void setRs3(String roomstu3) {
      this.roomstu3=roomstu3;
}
public String getRs3() {
      return roomstu3;
}
public void setRs4(String roomstu4) {
      this.roomstu1=roomstu4;
}
public String getRs4() {
      return roomstu4;
}
public void setHYGS(int  hygscore) {
      this.hygscore=hygscore;
}
public int getHYGS() {
      return hygscore;
}
 }
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
package XuShexinxi;
import java.util.ArrayList;
import java.util.Scanner;
 
 
public class Zhulei {
    Scanner sc=new Scanner(System.in);
    public static void main(String[] args) {
        ArrayList<RoomInformation> ar = new ArrayList<RoomInformation>();
        RoomInformation s1 = new RoomInformation("9#101","20214102","20214112","20214122","20214132",0);
        RoomInformation s2 = new RoomInformation("9#102","20214103","20214112","20214122","20214132",0);
        RoomInformation s3 = new RoomInformation("9#103","20214104","20214112","20214122","20214132",0);
        RoomInformation s4 = new RoomInformation("9#104","","","20214122","20214132",0);
        RoomInformation s5 = new RoomInformation("9#105","20214106","20214112","20214122","20214132",0);
        RoomInformation s6 = new RoomInformation("9#106","20214107","","20214122","20214132",0);
        RoomInformation s7 = new RoomInformation("9#107","20214108","","20214122","20214132",0);
        RoomInformation s8 = new RoomInformation("9#108","20214109","20214112","","20214132",0);
        RoomInformation s9 = new RoomInformation("9#109","","","20214122","20214132",0);
        RoomInformation s10 = new RoomInformation("9#110","","","","",0);
        ar.add(s1);
        ar.add(s2);
        ar.add(s3);
        ar.add(s4);
        ar.add(s5);
        ar.add(s6);
        ar.add(s7);
        ar.add(s8);
        ar.add(s9);
        ar.add(s10);
        while(true) {
            System.out.println("***************************************");
            System.out.println("\t\t石家庄铁道大学");
            System.out.println("\t    学生公寓管理系统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("6.退出系统");
            System.out.println("请选择系统功能");
            System.out.println("***************************************");
            Scanner sc = new Scanner(System.in);
            String choice =sc.nextLine();
            switch(choice) {
            case "1":
                findsu(ar);
                break;
            case "2":
                xing(ar);
                break;
            case "3":
                tiao(ar);
                break;
            case "4":
                ping(ar);
                break;
            case "5":
                cha(ar);
            case "6":
                default:
                    System.out.println("谢谢使用");
                    System.exit(0);
            }
        }
}
        public static void findsu(ArrayList<RoomInformation> ar) {
            if(ar.size()==0) {
                System.out.println("无信息,请重新选择");
                return ;
            }
            System.out.println("--------------------------------------");
            System.out.println("\t\t石家庄铁道大学");
            System.out.println("\t学生公寓管理系统v2022");
            System.out.println("--------------------------------------");
            System.out.println("宿舍信息列表");
            for(int i=0;i<ar.size();i++) {
                    int k=4;
                    RoomInformation s=ar.get(i);
                if(s.getRs1().equals("")) {k--;}
                if(s.getRs2().equals("")) {k--;}
                if(s.getRs3().equals("")) {k--;}
                if(s.getRs4().equals("")) {k--;}
                if(k==4)
                System.out.println(i+1+"、"+s.getRH()+"\t4人"+"\t已满");
                if(k==3)
                    System.out.println(i+1+"、"+s.getRH()+"\t3人"+"\t空1人");
                if(k==2)
                    System.out.println(i+1+"、"+s.getRH()+"\t2人"+"\t空2人");
                if(k==1)
                    System.out.println(i+1+"、"+s.getRH()+"\t1人"+"\t空3人");
                if(k==0)
                    System.out.println(i+1+"、"+s.getRH()+"\t0人"+"\t空宿舍");
 
            }
            System.out.println("***************************************");
        }
        public static void xing(ArrayList<RoomInformation> array) {
            for(int i=0;i<array.size();i++) {
                int k=4;
                RoomInformation s=array.get(i);
            if(s.getRs1().equals("")) {k--;}
            if(s.getRs2().equals("")) {k--;}
            if(s.getRs3().equals("")) {k--;}
            if(s.getRs4().equals("")) {k--;}
            if(k==0)
            {
                System.out.println("****************************************");
                System.out.println("\t\t石家庄铁道大学");
                System.out.println("\t  学生公寓管理系统v2022");
                System.out.println("\t\t安排新宿舍");
                System.out.println("****************************************");
                System.out.println(i+1+"、"+s.getRH()+"空宿舍");   
                s.setHYGS(5);
            }
            }
            Scanner sc =new Scanner(System.in);
            String No;
            System.out.println("请输入新宿舍号:");
            System.out.println("****************************************");
            No=sc.nextLine();
            for(int j=0;j<array.size();j++) {
                RoomInformation ss= array.get(j);
                if(ss.getRH().equals(No)&&ss.getHYGS()==5) {
                            System.out.println("1、床位1:XXXXX(学号1)");
                            String stu1=sc.nextLine();
                            System.out.println("2、床位2:XXXXX(学号2)");
                            String stu2=sc.nextLine();
                            System.out.println("3、床位3:XXXXX(学号3)");
                            String stu3=sc.nextLine();
                            System.out.println("4、床位4:XXXXX(学号4)");
                            String stu4=sc.nextLine();
                            ss.setRs1(stu1);
                            ss.setRs2(stu2);
                            ss.setRs3(stu3);
                            ss.setRs4(stu4);
                            System.out.println("该宿舍已满");
                            break;
                }
                if(ss.getRH().equals(No)&&ss.getHYGS()==0) {
                    System.out.println("不是空宿舍,无法安排新生");
                }
            }
        }
        public static void tiao(ArrayList<RoomInformation> array) {
            for(int i=0;i<array.size();i++) {
                int k=4;
                RoomInformation s=array.get(i);
            if(s.getRs1().equals("")) {k--;}
            if(s.getRs2().equals("")) {k--;}
            if(s.getRs3().equals("")) {k--;}
            if(s.getRs4().equals("")) {k--;}
            if(k==3)
                {System.out.println(i+1+"、"+s.getRH()+"\t 3人"+"\t空1人");
                s.setHYGS(k);
                }
            if(k==2)
                {System.out.println(i+1+"、"+s.getRH()+"\t 2人"+"\t空2人");
                s.setHYGS(k);
                }
            if(k==1)
                {System.out.println(i+1+"、"+s.getRH()+"\t 1人"+"\t空3人");
                s.setHYGS(k);
                }
            }
            Scanner sc =new Scanner(System.in);
            String No;
            System.out.println("请输入宿舍号:");
            No=sc.nextLine();
            boolean flag =true;
            for(int j=0;j<array.size();j++) {
                RoomInformation ss= array.get(j);
                if(ss.getRH().equals(No)&&ss.getHYGS()==3) {
                            System.out.println("2、床位2:XXXXX(学号2)");
                            String stu2=sc.nextLine();
                            ss.setRs2(stu2);
                            System.out.println("该宿舍已满");
                            break;
                }
                if(ss.getRH().equals(No)&&ss.getHYGS()==2) {
                    System.out.println("1、床位1:XXXXX(学号2)");
                    String stu1=sc.nextLine();
                    System.out.println("2、床位2:XXXXX(学号2)");
                    String stu2=sc.nextLine();
                    ss.setRs1(stu1);
                    ss.setRs2(stu2);
                    System.out.println("该宿舍已满");
                    break;
        }
                if(ss.getRH().equals(No)&&ss.getHYGS()==1) {
                    System.out.println("2、床位2:XXXXX(学号2)");
                    String stu2=sc.nextLine();
                    ss.setRs2(stu2);
                    System.out.println("该宿舍已满");
                    break;
        }
                if(ss.getRH().equals(No)&&ss.getHYGS()==0) {
                    System.out.println("该宿舍没有空床位,无法调整");   
                }
            }
            }
        public static void ping(ArrayList<RoomInformation> array) {
            for(int i=0;i<array.size();i++) {
                int k=4;
                RoomInformation s=array.get(i);
            if(s.getRs1().equals("")) {k--;}
            if(s.getRs2().equals("")) {k--;}
            if(s.getRs3().equals("")) {k--;}
            if(s.getRs4().equals("")) {k--;}
            s.setHYGS(k);
            }
            String N;
            System.out.println("请输入评价的宿舍号:");
            Scanner sc =new Scanner(System.in);
            N=sc.nextLine();
            for(int j=0;j<array.size();j++) {
                RoomInformation ss= array.get(j);
                if(ss.getRH().equals(N)&&ss.getHYGS()==0) {
                            System.out.println("该宿舍为空宿舍");
                            break;     
                }
                if(ss.getRH().equals(N)&&ss.getHYGS()!=0) {
                    System.out.println("宿舍号:"+ss.getRH());
                    if(ss.getRs1()!="")
                    System.out.println("学号:"+ss.getRs1());
                    if(ss.getRs2()!="")
                    System.out.println("学号:"+ss.getRs2());
                    if(ss.getRs3()!="")
                    System.out.println("学号:"+ss.getRs3());
                    if(ss.getRs4()!="")
                    System.out.println("学号:"+ss.getRs4());
                    System.out.println("输入宿舍卫生评价分数:XXXXXXX");
                    System.out.println("***************************************");
                    int a;
                    a=sc.nextInt();
                    ss.setHYGS(a);
                }
            }
        }
        public static void cha(ArrayList<RoomInformation> ar) {
            System.out.println("--------------------------------------");
            System.out.println("\t\t石家庄铁道大学");
            System.out.println("\t学生公寓管理系统v2022");
            System.out.println("--------------------------------------");
            System.out.println("\t卫生检查信息");
            for(int i=0;i<ar.size();i++) {
                RoomInformation s=ar.get(i);
               if(s.getHYGS()>5&&s.getHYGS()>90)  System.out.println(i+1+"、"+s.getRH()+"  "+s.getHYGS()+"  优秀");
               if(s.getHYGS()>5&&s.getHYGS()>80&&s.getHYGS()<90)   System.out.println(i+1+"、"+s.getRH()+"  "+s.getHYGS()+"  良好");
               if(s.getHYGS()>5&&s.getHYGS()>60&&s.getHYGS()<80)   System.out.println(i+1+"、"+s.getRH()+"  "+s.getHYGS()+"  合格");
               if(s.getHYGS()>5&&s.getHYGS()<60)  System.out.println(i+1+"、"+s.getRH()+"  "+s.getHYGS()+"  不合格");
        }
             
            }
}

  最后我也意识到我的不足之处:对代码的找错能力真的是离谱,难道就不能静下心来仔细地看看吗?写代码时不考虑有没有漏洞,有没有出错,这样写

有什么结果都是我以后考虑的,今后我一定会以这次的不及格为警戒,提升自己,写代码时出错不慌,仔细地从出错的地方理清思路,万万不能再像今天这样

手忙脚乱,慌不择路,最后只能成为不及格的人,一定会警记今天的失败,今后细心细心再细心,努力努力再努力,提升自己是必须的!