Java开学考试感想及代码

本次开学考试是对Java基础的考察,做的是一个公寓宿舍管理系统,比上届的论文查重系统简单的多,但结果却差强人意,

在家中的学习和练习还不够,导致编程的时候题目的功能并不能实现,最后导致编程的结果不尽人意。

最后在学习Java的过程中我得出这样的结论:

1.学习中,要养成良好的习惯(写括号时要成对,字母大小写要区分,单词拼写要准确)。

2.在学习的过程中,最好不是仅仅停留在java表层,不是抄书上的例子运行出结果就可以。要注意,即便对一个简单的例子也要有耐心去琢磨、调试、改动。

3.在学习的过程中一定要动手做、试着写代码,而不是抱一本书看看就行。很多东西和体会必须自己动手才能真正属于自己。

4. 在 Java 的学习过程中,可能会遇到形形色色的问题不容易解决,应多去专业论坛了解相关的知识,书本上的知识有限。要会从网上搜索有用的信息 加以整理,促进学习的深入和知识水平的提高。

看了好多网上课程,说学到一定程度要尝试着自己做东西,但觉得自己仅仅经过一学期的学习,还远远不够,希望自己在以后学习中继续努力,能够真真正正拥有一门编程语言,对自己今后的发展起到作用。在学习java语言的同时,也让我学会了如何来发现问题,如何解决问题,怎样有效的学习等等,相信会对我一生都有帮助。

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
package test;
 
public class RoomInformation {
     private String roomno;
     private String stunno1;
     private String stunno2;
     private String stunno3;
     private String stunno4;
     private int hygienescore;
     
    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;
    }
      
}

  

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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
package test;
 
import java.util.Scanner;
 
public class RoomManagement {
      static Scanner sc=null;
      static RoomInformation[] s = new RoomInformation[10];
     
      public static void main(String[] args) {
          sc=new Scanner(System.in);
        RoomInformation s0 = new RoomInformation("9#101","20213000","20213001","20213002","20213003",0);
        RoomInformation s1 = new RoomInformation("9#102","20213100","20213101","20213102","20213103",0);
        RoomInformation s2 = new RoomInformation("9#103","20213200","20213201","20213202","",0);
        RoomInformation s3 = new RoomInformation("9#104","20213300","","","",0);
        RoomInformation s4 = new RoomInformation("9#105","20213400","20213401","","",0);
        RoomInformation s5 = new RoomInformation("9#106","20213500","20213501","20213502","20213503",0);
        RoomInformation s6 = new RoomInformation("9#107","20213600","20213601","20213602","20213603",0);
        RoomInformation s7 = new RoomInformation("9#108","","","","",0);
        RoomInformation s8 = new RoomInformation("9#109","","","","",0);
        RoomInformation s9 = new RoomInformation("9#110","","","","",0);
        s[0]=s0;
        s[1]=s1;
        s[2]=s2;
        s[3]=s3;
        s[4]=s4;
        s[5]=s5;
        s[6]=s6;
        s[7]=s7;
        s[8]=s8;
        s[9]=s9;
        while(true) {
        show();
        System.out.println("请输入你的选择:");
        int a=sc.nextInt();
        if(a>6||a<1) {
            System.out.println("该选项不存在");
            continue;
        }
        if(a==6) System.exit(0);
        switch(a) {
        case 1:sushechaxun();break;
        case 2:anpaixinsushe();break;
        case 3:tiaozhengsushe();break;
        case 4:susheweishengpingjia();break;
        case 5:weishengjianchaqingkuang();break;
        }
        }
         
    }
       
     public static void show() {
        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 String zhuangtai(RoomInformation c){
          int count=0;
          StringBuilder s=new StringBuilder("");
          if(c.getStunno1().length()!=0) count++;
          if(c.getStunno2().length()!=0) count++;
          if(c.getStunno3().length()!=0) count++;
          if(c.getStunno4().length()!=0) count++;
          if(count==0) s.append("空宿舍");
          if(count==1) s.append("空3人");
          if(count==2) s.append("空2人");
          if(count==3) s.append("空1人");
          if(count==4) s.append("已满");
          return s.toString();
     }
      
     public static int renshu(RoomInformation c){
      int count=0;
      if(c.getStunno1().length()!=0) count++;
      if(c.getStunno2().length()!=0) count++;
      if(c.getStunno3().length()!=0) count++;
      if(c.getStunno4().length()!=0) count++;
      return count;
    }
      
     public static void sushechaxun(){
            System.out.println("***********************************************************");
            System.out.println("                      石家庄铁道大学                           ");
            System.out.println("                  学生公寓管理系统v2022                        ");
            System.out.println("***********************************************************");
            System.out.println("                     宿舍详细信息列表                          ");
        for(int i=0;i<10;i++)
            System.out.println("                    "+(i+1)+"、"+"  "+s[i].getRoomno()+"  "
             +renshu(s[i])+"人  "+zhuangtai(s[i])+"                    ");
            System.out.println("***********************************************************");
    }
      
     public static int anpaixinsushe() {
            int count=0;
            int k=0;
            System.out.println("***********************************************************");
            System.out.println("                      石家庄铁道大学                           ");
            System.out.println("                  学生公寓管理系统v2022                        ");
            System.out.println("                       安排新宿舍                             ");
            System.out.println("***********************************************************");
            System.out.println("                    空宿舍详细信息列表                          ");
            for(int i=0;i<10;i++)
               if(renshu(s[i])==0) {
                   count++;
                System.out.println("                    "+count+"、"+"  "+s[i].getRoomno()+"  "
                        +renshu(s[i])+"人  "+zhuangtai(s[i])+"                    ");
               }
            System.out.print("                    请输入新宿舍号:");
            String a=sc.next();
            int r=0;
            for(int i=0;i<10;i++)
            if(a.equals(s[i].getRoomno())) {
                if(renshu(s[i])==0)
                    r=1;
                k=i;
                break;
            }
            if(r==0) {System.out.println("该宿舍不是空宿舍,无法安排新生");}
            if(r==1) {
                System.out.println("***********************************************************\r\n"
                                 + "                     石家庄铁道大学\r\n"
                                 + "                  学生公寓管理系统v2022\r\n"
                                 + "                     安排新宿舍\r\n"
                                 + "***********************************************************\r\n"
                                 + "                      新宿舍号:");
                System.out.println("                      1、床位1:");
                System.out.println("                      2、床位2:");
                System.out.println("                      3、床位3:");
                System.out.println("                      4、床位4:");
                String a1=sc.next();
                while(panduan(a1)==0) {
                    System.out.println("该学生已分配宿舍");
                    System.out.println("请重新输入");
                    a1=sc.next();
                }
                if(a1.equals("END")) return 1;
                else s[k].setStunno1(a1);
                String a2=sc.next();
                while(panduan(a2)==0) {
                    System.out.println("该学生已分配宿舍");
                    System.out.println("请重新输入");
                    a2=sc.next();
                }
                if(a2.equals("END")) return 1;
                else s[k].setStunno1(a2);
                String a3=sc.next();
                while(panduan(a3)==0) {
                    System.out.println("该学生已分配宿舍");
                    System.out.println("请重新输入");
                    a3=sc.next();
                }
                if(a3.equals("END")) return 1;
                else s[k].setStunno1(a3);
                String a4=sc.next();
                while(panduan(a4)==0) {
                    System.out.println("该学生已分配宿舍");
                    System.out.println("请重新输入");
                    a4=sc.next();
                }
                if(a4.equals("END")) return 1;
                else  s[k].setStunno1(a4);System.out.println("该宿舍已满");
            }
            return 1;
     }
      
     public static int panduan(String a) {
          
         for(int i=0;i<10;i++){
             int count=0;
             if(a.equals(s[i].getStunno1())) count++;
             if(a.equals(s[i].getStunno2())) count++;
             if(a.equals(s[i].getStunno3())) count++;
             if(a.equals(s[i].getStunno4())) count++;
             if(count!=0) return 0;
         }
         return 1;
     }
      
     public static int tiaozhengsushe() {
            int count=0;
            int k=0;
            System.out.println("***********************************************************");
            System.out.println("                      石家庄铁道大学                           ");
            System.out.println("                  学生公寓管理系统v2022                        ");
            System.out.println("                        调整宿舍                              ");
            System.out.println("***********************************************************");
            System.out.println("                    有空床位宿舍详细信息列表                      ");
            for(int i=0;i<10;i++)
                if(renshu(s[i])>0&&renshu(s[i])<4) {
                       count++;
                    System.out.println("                    "+count+"、"+"  "+s[i].getRoomno()+"  "
                            +renshu(s[i])+"人  "+zhuangtai(s[i])+"                    ");
                   }
            System.out.print("                    请输入待调整宿舍号:");
            String a=sc.next();
            int r=0;
            for(int i=0;i<10;i++)
            if(a.equals(s[i].getRoomno())) {
                if(renshu(s[i])>=1&&renshu(s[i])<=3)
                    r=1;
                k=i;
                break;
            }
            if(r==0) {System.out.println("该宿舍没有空床位,无法调整");}
            if(r==1) {
                int i=0;
                System.out.println("***********************************************************\r\n"
                                 + "                     石家庄铁道大学\r\n"
                                 + "                  学生公寓管理系统v2022\r\n"
                                 + "                       调整宿舍\r\n"
                                 + "***********************************************************\r\n"
                                 + "                      待调整宿舍号:");
                if(s[k].getStunno1().length()!=0
                    i++;
                System.out.println("                     1、床位1: "+s[k].getStunno1());
                if(s[k].getStunno2().length()!=0)
                    i++;
                System.out.println("                     2、床位2: "+s[k].getStunno2());
                if(s[k].getStunno3().length()!=0)
                    i++;
                System.out.println("                     3、床位3: "+s[k].getStunno3());
                if(s[k].getStunno4().length()!=0)
                    i++;
                System.out.println("                     4、床位4: "+s[k].getStunno4());
                String a1=sc.next();
                while(panduan(a1)==0) {
                    System.out.println("该学生已分配宿舍");
                    System.out.println("请重新输入");
                    a1=sc.next();
                }
                if(a1.equals("END")) return 1;
                else {if(s[k].getStunno1().length()==0) s[k].setStunno1(a1);
                      else  if(s[k].getStunno2().length()==0) s[k].setStunno2(a1);
                      else  if(s[k].getStunno3().length()==0) s[k].setStunno3(a1);
                      else  s[k].setStunno4(a1);
                      }
                i++;
                if(i!=4) {
                String a2=sc.next();
                while(panduan(a2)==0) {
                    System.out.println("该学生已分配宿舍");
                    System.out.println("请重新输入");
                    a2=sc.next();
                }
                if(a2.equals("END")) return 1;
                else {if(s[k].getStunno1().length()==0) s[k].setStunno1(a2);
                      else  if(s[k].getStunno2().length()==0) s[k].setStunno2(a2);
                      else  if(s[k].getStunno3().length()==0) s[k].setStunno3(a2);
                     else  s[k].setStunno4(a2);
                     }
                }
                else {System.out.println("该宿舍已满"); return 1;}
                i++;
                if(i!=4) {
                String a3=sc.next();
                while(panduan(a3)==0) {
                    System.out.println("该学生已分配宿舍");
                    System.out.println("请重新输入:");
                    a3=sc.next();
                }
                if(a3.equals("END")) return 1;
                else {if(s[k].getStunno1().length()==0) s[k].setStunno1(a3);
                      else  if(s[k].getStunno2().length()==0) s[k].setStunno2(a3);
                      else  if(s[k].getStunno3().length()==0) s[k].setStunno3(a3);
                     else  s[k].setStunno4(a3);
                     }
                }
                else {System.out.println("该宿舍已满"); return 1;}
                 
            }
            return 1;
     }
      
     public static void susheweishengpingjia() {
            int r=0;
            int k=0;
            while(r==0) {
            System.out.println("***********************************************************");
            System.out.println("                      石家庄铁道大学                           ");
            System.out.println("                  学生公寓管理系统v2022                        ");
            System.out.println("                       宿舍卫生评价                           ");
            System.out.println("***********************************************************");
            System.out.println("                    请输入待评价宿舍号:");
            String a=sc.next();
            for(int i=0;i<10;i++)
            if(a.equals(s[i].getRoomno())) {
                if(renshu(s[i])!=0)
                    r=1;
                k=i;
                break;
            }
            if(r==0) {System.out.println("该宿舍为空宿舍");}
            if(r==1) {
                System.out.println("                    1、"+"床位1  "
                 +s[k].getStunno1()+"                      ");
                System.out.println("                    2、"+"床位2  "
                     +s[k].getStunno1()+"                      ");
                System.out.println("                    3、"+"床位3  "
                     +s[k].getStunno1()+"                      ");
                System.out.println("                    4、"+"床位4  "
                     +s[k].getStunno1()+"                      ");
                System.out.println("输入宿舍卫生评价分数:");
                int w=sc.nextInt();
                while(w>100||w<0){
                    System.out.println("输入错误");
                    System.out.println("请重新输入:");
                    w=sc.nextInt();
                    }
                s[k].setHygienescore(w);
            }
            }
     }
      
      public static String weishengdengji(RoomInformation c){
      StringBuilder s=new StringBuilder("");
      if(c.getHygienescore()>=90) s.append("优秀");
      else if(c.getHygienescore()>=80) s.append("良好");
      else if(c.getHygienescore()>=60) s.append("合格");
      else  s.append("不合格");
      return s.toString();
      }
      
     public static void weishengjianchaqingkuang() {
            System.out.println("***********************************************************");
            System.out.println("                      石家庄铁道大学                           ");
            System.out.println("                  学生公寓管理系统v2022                        ");
            System.out.println("                      卫生检查情况查询                           ");
            System.out.println("***********************************************************");
            System.out.println("                     宿舍卫生检查情况信息                        ");
            for(int i=0;i<10;i++)
                System.out.println("                    "+(i+1)+"、"+"  "+s[i].getRoomno()+"  "
                 +s[i].getHygienescore()+"   "+weishengdengji(s[i]));
                System.out.println("***********************************************************");
     }
      
}

  

posted @   一统天下。  阅读(24)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!
点击右上角即可分享
微信分享提示