├── .gitignore
├── Animal.txt
├── build.xml
├── build
└── classes
│ ├── .netbeans_automatic_build
│ ├── .netbeans_update_resources
│ ├── dao
│ └── File_DAO.class
│ ├── data
│ ├── Animal.class
│ ├── AnimalList.class
│ ├── FourLeg.class
│ ├── NoLeg.class
│ ├── TwoLegCanFly.class
│ └── TwoLegNoFly.class
│ ├── run
│ └── Program.class
│ └── validation
│ └── Check.class
├── manifest.mf
├── nbproject
├── build-impl.xml
├── genfiles.properties
├── private
│ ├── private.properties
│ └── private.xml
├── project.properties
└── project.xml
└── src
├── dao
└── File_DAO.java
├── data
├── Animal.java
├── AnimalList.java
├── FourLeg.java
├── NoLeg.java
├── TwoLegCanFly.java
└── TwoLegNoFly.java
├── run
└── Program.java
└── validation
└── Check.java
/.gitignore:
--------------------------------------------------------------------------------
1 | # Created by https://www.toptal.com/developers/gitignore/api/netbeans
2 | # Edit at https://www.toptal.com/developers/gitignore?templates=netbeans
3 |
4 | ### NetBeans ###
5 | **/nbproject/private/
6 | **/nbproject/Makefile-*.mk
7 | **/nbproject/Package-*.bash
8 | build/
9 | nbbuild/
10 | dist/
11 | nbdist/
12 | .nb-gradle/
13 |
14 | # End of https://www.toptal.com/developers/gitignore/api/netbeans
--------------------------------------------------------------------------------
/Animal.txt:
--------------------------------------------------------------------------------
1 | AA1111;Phuong;0;ij ij ij ijj;219.0
2 | AA1212;Peter kun;2;Not lazy;66.6;2;Can fly
3 | AA2121;Quyen;2;Lazyyyy;36.0;2;No Fly
4 | AA2222;thuy;2;So funny;36.0;2;Can fly
5 | AA3333;Be;4;So sad;35.0
6 | AA3334;Diep;4;So smart;35.0
7 | AA9191;Lan;0;So intelligent;921.0
8 | AA9999;NoName;0;So happyyyy;91.0
9 | AS9191;Bao;2;Funny funny;312.0;2;No Fly
10 | IA9191;Bao;2;So stressfull;912.0;2;Can fly
11 | JA1818;Kinh;0;So borrow;939.0
12 | SA1919;Quang;2;So happy;291.0;2;Can fly
13 | SA9911;An;4;No pain no gain;921.0
14 |
--------------------------------------------------------------------------------
/build.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 | Builds, tests, and runs the project Zoo Management.
12 |
13 |
73 |
74 |
--------------------------------------------------------------------------------
/build/classes/.netbeans_automatic_build:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peter66-dev/Zoo-Management/e33b9aa601ce08e50d2bad98f51e1803ea704856/build/classes/.netbeans_automatic_build
--------------------------------------------------------------------------------
/build/classes/.netbeans_update_resources:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peter66-dev/Zoo-Management/e33b9aa601ce08e50d2bad98f51e1803ea704856/build/classes/.netbeans_update_resources
--------------------------------------------------------------------------------
/build/classes/dao/File_DAO.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peter66-dev/Zoo-Management/e33b9aa601ce08e50d2bad98f51e1803ea704856/build/classes/dao/File_DAO.class
--------------------------------------------------------------------------------
/build/classes/data/Animal.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peter66-dev/Zoo-Management/e33b9aa601ce08e50d2bad98f51e1803ea704856/build/classes/data/Animal.class
--------------------------------------------------------------------------------
/build/classes/data/AnimalList.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peter66-dev/Zoo-Management/e33b9aa601ce08e50d2bad98f51e1803ea704856/build/classes/data/AnimalList.class
--------------------------------------------------------------------------------
/build/classes/data/FourLeg.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peter66-dev/Zoo-Management/e33b9aa601ce08e50d2bad98f51e1803ea704856/build/classes/data/FourLeg.class
--------------------------------------------------------------------------------
/build/classes/data/NoLeg.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peter66-dev/Zoo-Management/e33b9aa601ce08e50d2bad98f51e1803ea704856/build/classes/data/NoLeg.class
--------------------------------------------------------------------------------
/build/classes/data/TwoLegCanFly.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peter66-dev/Zoo-Management/e33b9aa601ce08e50d2bad98f51e1803ea704856/build/classes/data/TwoLegCanFly.class
--------------------------------------------------------------------------------
/build/classes/data/TwoLegNoFly.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peter66-dev/Zoo-Management/e33b9aa601ce08e50d2bad98f51e1803ea704856/build/classes/data/TwoLegNoFly.class
--------------------------------------------------------------------------------
/build/classes/run/Program.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peter66-dev/Zoo-Management/e33b9aa601ce08e50d2bad98f51e1803ea704856/build/classes/run/Program.class
--------------------------------------------------------------------------------
/build/classes/validation/Check.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/peter66-dev/Zoo-Management/e33b9aa601ce08e50d2bad98f51e1803ea704856/build/classes/validation/Check.class
--------------------------------------------------------------------------------
/manifest.mf:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | X-COMMENT: Main-Class will be added automatically by build
3 |
4 |
--------------------------------------------------------------------------------
/nbproject/build-impl.xml:
--------------------------------------------------------------------------------
1 |
2 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
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 | Must set src.dir
234 | Must set test.src.dir
235 | Must set build.dir
236 | Must set dist.dir
237 | Must set build.classes.dir
238 | Must set dist.javadoc.dir
239 | Must set build.test.classes.dir
240 | Must set build.test.results.dir
241 | Must set build.classes.excludes
242 | Must set dist.jar
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 | Must set javac.includes
344 |
345 |
346 |
347 |
348 |
349 |
350 |
351 |
352 |
353 |
354 |
355 |
356 |
357 |
358 |
359 |
360 |
361 |
362 |
363 |
364 |
365 |
366 |
367 |
368 |
369 |
370 |
371 |
372 |
373 |
374 |
375 |
376 |
377 |
378 |
379 |
380 |
381 |
382 |
383 |
384 |
385 |
386 |
387 |
388 |
389 |
390 |
391 |
392 |
393 |
394 |
395 |
396 |
397 |
398 |
399 |
400 |
401 |
402 |
403 |
404 |
405 |
406 |
407 |
408 |
409 |
410 |
411 |
412 |
413 |
414 |
415 |
416 |
417 |
418 |
419 |
420 |
421 |
422 |
423 |
424 |
425 |
426 |
427 |
428 |
429 |
430 |
431 |
432 |
433 |
434 |
435 |
436 |
437 |
438 |
439 |
440 |
441 |
442 |
443 |
444 |
445 |
446 |
447 |
448 |
449 |
450 |
451 |
452 |
453 |
454 |
455 |
456 |
457 |
458 |
459 |
460 |
461 |
462 |
463 |
464 |
465 |
466 |
467 |
468 |
469 |
470 |
471 |
472 | No tests executed.
473 |
474 |
475 |
476 |
477 |
478 |
479 |
480 |
481 |
482 |
483 |
484 |
485 |
486 |
487 |
488 |
489 |
490 |
491 |
492 |
493 |
494 |
495 |
496 |
497 |
498 |
499 |
500 |
501 |
502 |
503 |
504 |
505 |
506 |
507 |
508 |
509 |
510 |
511 |
512 |
513 |
514 |
515 |
516 |
517 |
518 |
519 |
520 |
521 |
522 |
523 |
524 |
525 |
526 |
527 |
528 |
529 |
530 |
531 |
532 |
533 |
534 |
535 |
536 |
537 |
538 |
539 |
540 |
541 |
542 |
543 |
544 |
545 |
546 |
547 |
548 |
549 |
550 |
551 |
552 |
553 |
554 |
555 |
556 |
557 |
558 |
559 |
560 |
561 |
562 |
563 |
564 |
565 |
566 |
567 |
568 |
569 |
570 |
571 |
572 |
573 |
574 |
575 |
576 |
577 |
578 |
579 |
580 |
581 |
582 |
583 |
584 |
585 |
586 |
587 |
588 |
589 |
590 |
591 |
592 |
593 |
594 |
595 |
596 |
597 |
598 |
599 |
600 |
601 |
602 |
603 |
604 |
605 |
606 |
607 |
608 |
609 |
610 |
611 |
612 |
613 |
614 |
615 |
616 |
617 |
618 |
619 |
620 |
621 |
622 |
623 |
624 |
625 |
626 |
627 |
628 |
629 |
630 |
631 |
632 |
633 |
634 |
635 |
636 |
637 |
638 |
639 |
640 |
641 |
642 |
643 |
644 |
645 |
646 |
647 |
648 |
649 |
650 |
651 |
652 |
653 |
654 |
655 |
656 |
657 |
658 |
659 |
660 |
661 |
662 |
663 |
664 |
665 |
666 |
667 |
668 |
669 |
670 |
671 |
672 |
673 |
674 |
675 |
676 |
677 |
680 |
681 |
682 |
683 |
684 |
685 |
686 |
687 |
688 |
689 |
690 |
691 |
692 |
693 |
694 |
695 |
696 |
697 |
698 |
699 |
700 |
701 |
702 |
703 |
704 |
705 |
706 |
707 |
708 |
709 |
710 |
711 |
712 |
713 |
714 |
715 |
716 |
717 |
718 |
719 |
720 |
721 |
722 | Must set JVM to use for profiling in profiler.info.jvm
723 | Must set profiler agent JVM arguments in profiler.info.jvmargs.agent
724 |
725 |
728 |
729 |
730 |
731 |
732 |
733 |
734 |
735 |
736 |
737 |
738 |
739 |
740 |
741 |
742 |
743 |
744 |
745 |
746 |
747 |
748 |
749 |
750 |
751 |
752 |
753 |
754 |
755 |
756 |
757 |
758 |
759 |
760 |
761 |
762 |
763 |
764 |
765 |
766 |
767 |
768 |
769 |
770 |
771 |
772 |
773 |
774 |
775 |
776 |
777 |
778 |
779 |
780 |
781 |
782 |
783 |
784 |
785 |
786 |
787 |
788 |
789 |
790 |
791 |
792 |
793 |
794 |
795 |
796 |
797 |
798 |
799 |
800 |
801 |
802 |
803 |
804 |
805 |
806 |
807 |
808 |
809 |
810 |
811 |
812 |
813 |
814 |
815 |
816 |
817 |
818 |
819 |
820 |
821 |
822 |
823 |
824 |
825 |
826 |
827 |
828 |
829 |
830 |
831 |
832 |
833 |
834 |
835 |
836 |
837 |
838 |
839 |
840 |
841 |
842 |
843 |
844 |
845 |
846 |
847 |
848 |
849 |
850 |
851 |
852 |
853 |
854 |
855 |
856 |
857 |
858 |
859 |
860 |
861 |
862 |
863 |
864 |
865 |
866 |
867 |
868 |
869 |
870 |
871 |
872 |
873 |
874 |
875 |
876 |
877 |
878 |
879 |
880 |
881 |
882 |
883 |
884 |
885 |
886 |
891 |
892 |
893 |
894 |
895 |
896 |
897 |
898 |
899 |
900 |
901 |
902 |
903 |
904 |
905 |
906 |
907 |
908 |
909 |
910 |
911 |
912 |
913 |
914 |
915 |
916 |
917 |
918 |
919 |
920 |
921 |
922 |
923 |
924 |
925 |
926 |
927 |
928 |
929 |
930 |
931 |
932 |
933 |
934 |
935 |
936 |
937 |
938 |
939 |
940 |
941 |
942 |
943 |
944 |
945 |
946 |
947 |
948 |
949 |
950 |
951 | Must select some files in the IDE or set javac.includes
952 |
953 |
954 |
955 |
956 |
957 |
958 |
959 |
960 |
965 |
966 |
967 |
968 |
969 |
970 |
971 |
972 |
973 |
974 |
975 |
976 |
977 |
978 |
979 |
980 |
981 |
982 |
983 |
984 |
985 |
986 |
987 |
988 |
989 |
990 |
991 |
992 |
993 |
994 |
995 |
996 |
997 |
998 |
999 |
1000 |
1001 | To run this application from the command line without Ant, try:
1002 |
1003 | java -jar "${dist.jar.resolved}"
1004 |
1005 |
1006 |
1007 |
1008 |
1009 |
1010 |
1011 |
1012 |
1013 |
1014 |
1015 |
1016 |
1017 |
1018 |
1019 |
1020 |
1021 |
1022 |
1023 |
1024 |
1025 |
1026 |
1027 |
1028 |
1029 |
1030 |
1031 |
1032 |
1033 |
1034 |
1039 |
1040 |
1041 |
1042 |
1043 |
1044 |
1045 |
1046 |
1047 |
1048 |
1049 |
1050 | Must select one file in the IDE or set run.class
1051 |
1052 |
1053 |
1054 | Must select one file in the IDE or set run.class
1055 |
1056 |
1057 |
1062 |
1063 |
1064 |
1065 |
1066 |
1067 |
1068 |
1069 |
1070 |
1071 |
1072 |
1073 |
1074 |
1075 |
1076 |
1077 |
1078 |
1079 |
1080 |
1081 | Must select one file in the IDE or set debug.class
1082 |
1083 |
1084 |
1085 |
1086 | Must select one file in the IDE or set debug.class
1087 |
1088 |
1089 |
1090 |
1091 | Must set fix.includes
1092 |
1093 |
1094 |
1095 |
1096 |
1097 |
1098 |
1103 |
1106 |
1107 | This target only works when run from inside the NetBeans IDE.
1108 |
1109 |
1110 |
1111 |
1112 |
1113 |
1114 |
1115 |
1116 | Must select one file in the IDE or set profile.class
1117 | This target only works when run from inside the NetBeans IDE.
1118 |
1119 |
1120 |
1121 |
1122 |
1123 |
1124 |
1125 |
1126 | This target only works when run from inside the NetBeans IDE.
1127 |
1128 |
1129 |
1130 |
1131 |
1132 |
1133 |
1134 |
1135 |
1136 |
1137 |
1138 |
1139 | This target only works when run from inside the NetBeans IDE.
1140 |
1141 |
1142 |
1143 |
1144 |
1145 |
1146 |
1147 |
1148 |
1149 |
1150 |
1151 |
1152 |
1153 |
1154 |
1155 |
1156 |
1157 |
1158 |
1159 |
1160 |
1161 |
1164 |
1165 |
1166 |
1167 |
1168 |
1169 |
1170 |
1171 |
1172 |
1173 |
1174 |
1175 |
1176 |
1177 | Must select one file in the IDE or set run.class
1178 |
1179 |
1180 |
1181 |
1182 |
1183 | Must select some files in the IDE or set test.includes
1184 |
1185 |
1186 |
1187 |
1188 | Must select one file in the IDE or set run.class
1189 |
1190 |
1191 |
1192 |
1193 | Must select one file in the IDE or set applet.url
1194 |
1195 |
1196 |
1197 |
1202 |
1203 |
1204 |
1205 |
1206 |
1207 |
1208 |
1209 |
1210 |
1211 |
1212 |
1213 |
1214 |
1215 |
1216 |
1217 |
1218 |
1219 |
1220 |
1221 |
1222 |
1223 |
1224 |
1225 |
1226 |
1227 |
1228 |
1229 |
1230 |
1231 |
1232 |
1233 |
1234 |
1235 |
1236 |
1237 |
1238 |
1239 |
1240 |
1241 |
1246 |
1247 |
1248 |
1249 |
1250 |
1251 |
1252 |
1253 |
1254 |
1255 |
1256 |
1257 |
1258 |
1259 |
1260 |
1261 |
1262 |
1263 |
1264 |
1265 |
1266 |
1267 |
1268 |
1269 |
1270 |
1271 |
1272 | Must select some files in the IDE or set javac.includes
1273 |
1274 |
1275 |
1276 |
1277 |
1278 |
1279 |
1280 |
1281 |
1282 |
1283 |
1284 |
1289 |
1290 |
1291 |
1292 |
1293 |
1294 |
1295 |
1296 | Some tests failed; see details above.
1297 |
1298 |
1299 |
1300 |
1301 |
1302 |
1303 |
1304 |
1305 | Must select some files in the IDE or set test.includes
1306 |
1307 |
1308 |
1309 | Some tests failed; see details above.
1310 |
1311 |
1312 |
1313 | Must select some files in the IDE or set test.class
1314 | Must select some method in the IDE or set test.method
1315 |
1316 |
1317 |
1318 | Some tests failed; see details above.
1319 |
1320 |
1321 |
1326 |
1327 | Must select one file in the IDE or set test.class
1328 |
1329 |
1330 |
1331 | Must select one file in the IDE or set test.class
1332 | Must select some method in the IDE or set test.method
1333 |
1334 |
1335 |
1336 |
1337 |
1338 |
1339 |
1340 |
1341 |
1342 |
1343 |
1344 |
1349 |
1350 | Must select one file in the IDE or set applet.url
1351 |
1352 |
1353 |
1354 |
1355 |
1356 |
1357 |
1362 |
1363 | Must select one file in the IDE or set applet.url
1364 |
1365 |
1366 |
1367 |
1368 |
1369 |
1370 |
1371 |
1376 |
1377 |
1378 |
1379 |
1380 |
1381 |
1382 |
1383 |
1384 |
1385 |
1386 |
1387 |
1388 |
1389 |
1390 |
1391 |
1392 |
1393 |
1394 |
1395 |
1396 |
1397 |
1398 |
1399 |
1400 |
1401 |
1402 |
1403 |
1404 |
1405 |
1406 |
1407 |
1408 |
1409 |
1410 |
1411 |
1412 |
1413 |
1414 |
1415 |
1416 |
1417 |
1418 |
1419 |
1420 |
1421 |
--------------------------------------------------------------------------------
/nbproject/genfiles.properties:
--------------------------------------------------------------------------------
1 | build.xml.data.CRC32=b64d2024
2 | build.xml.script.CRC32=961b8192
3 | build.xml.stylesheet.CRC32=8064a381@1.80.1.48
4 | # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
5 | # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
6 | nbproject/build-impl.xml.data.CRC32=b64d2024
7 | nbproject/build-impl.xml.script.CRC32=d39e5990
8 | nbproject/build-impl.xml.stylesheet.CRC32=830a3534@1.80.1.48
9 |
--------------------------------------------------------------------------------
/nbproject/private/private.properties:
--------------------------------------------------------------------------------
1 | compile.on.save=true
2 | user.properties.file=C:\\Users\\Dell\\AppData\\Roaming\\NetBeans\\8.2\\build.properties
3 |
--------------------------------------------------------------------------------
/nbproject/private/private.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/nbproject/project.properties:
--------------------------------------------------------------------------------
1 | annotation.processing.enabled=true
2 | annotation.processing.enabled.in.editor=false
3 | annotation.processing.processor.options=
4 | annotation.processing.processors.list=
5 | annotation.processing.run.all.processors=true
6 | annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
7 | build.classes.dir=${build.dir}/classes
8 | build.classes.excludes=**/*.java,**/*.form
9 | # This directory is removed when the project is cleaned:
10 | build.dir=build
11 | build.generated.dir=${build.dir}/generated
12 | build.generated.sources.dir=${build.dir}/generated-sources
13 | # Only compile against the classpath explicitly listed here:
14 | build.sysclasspath=ignore
15 | build.test.classes.dir=${build.dir}/test/classes
16 | build.test.results.dir=${build.dir}/test/results
17 | # Uncomment to specify the preferred debugger connection transport:
18 | #debug.transport=dt_socket
19 | debug.classpath=\
20 | ${run.classpath}
21 | debug.test.classpath=\
22 | ${run.test.classpath}
23 | # Files in build.classes.dir which should be excluded from distribution jar
24 | dist.archive.excludes=
25 | # This directory is removed when the project is cleaned:
26 | dist.dir=dist
27 | dist.jar=${dist.dir}/Zoo_Management.jar
28 | dist.javadoc.dir=${dist.dir}/javadoc
29 | excludes=
30 | includes=**
31 | jar.compress=false
32 | javac.classpath=
33 | # Space-separated list of extra javac options
34 | javac.compilerargs=
35 | javac.deprecation=false
36 | javac.external.vm=true
37 | javac.processorpath=\
38 | ${javac.classpath}
39 | javac.source=1.8
40 | javac.target=1.8
41 | javac.test.classpath=\
42 | ${javac.classpath}:\
43 | ${build.classes.dir}
44 | javac.test.processorpath=\
45 | ${javac.test.classpath}
46 | javadoc.additionalparam=
47 | javadoc.author=false
48 | javadoc.encoding=${source.encoding}
49 | javadoc.noindex=false
50 | javadoc.nonavbar=false
51 | javadoc.notree=false
52 | javadoc.private=false
53 | javadoc.splitindex=true
54 | javadoc.use=true
55 | javadoc.version=false
56 | javadoc.windowtitle=
57 | main.class=run.Program
58 | manifest.file=manifest.mf
59 | meta.inf.dir=${src.dir}/META-INF
60 | mkdist.disabled=false
61 | platform.active=default_platform
62 | run.classpath=\
63 | ${javac.classpath}:\
64 | ${build.classes.dir}
65 | # Space-separated list of JVM arguments used when running the project.
66 | # You may also define separate properties like run-sys-prop.name=value instead of -Dname=value.
67 | # To set system properties for unit tests define test-sys-prop.name=value:
68 | run.jvmargs=
69 | run.test.classpath=\
70 | ${javac.test.classpath}:\
71 | ${build.test.classes.dir}
72 | source.encoding=UTF-8
73 | src.dir=src
74 | test.src.dir=test
75 |
--------------------------------------------------------------------------------
/nbproject/project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | org.netbeans.modules.java.j2seproject
4 |
5 |
6 | Zoo Management
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/src/dao/File_DAO.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */
6 | package dao;
7 |
8 | import data.Animal;
9 | import data.FourLeg;
10 | import data.NoLeg;
11 | import data.TwoLegCanFly;
12 | import data.TwoLegNoFly;
13 | import java.io.BufferedReader;
14 | import java.io.FileReader;
15 | import java.io.PrintWriter;
16 | import java.util.TreeSet;
17 |
18 | /**
19 | *
20 | * @author Dell
21 | */
22 | public class File_DAO {
23 |
24 | public static TreeSet loadData(String filename) {
25 | TreeSet list = new TreeSet<>();
26 | FileReader fr = null;
27 | BufferedReader br = null;
28 | try {
29 | fr = new FileReader(filename);
30 | br = new BufferedReader(fr);
31 | while (br.ready()) {
32 | String s = new String();
33 | Animal obj = null;
34 | s = br.readLine();
35 | String[] animal = s.split(";");
36 | if (animal.length == 5 || animal.length == 7) {
37 | if (animal.length == 5) {
38 | int leg;
39 | leg = Integer.parseInt(animal[2]);
40 | if (leg == 0) {
41 | obj = new NoLeg(animal[0].toUpperCase(), animal[1], Double.parseDouble(animal[4]), animal[3]);
42 | } else {
43 | obj = new FourLeg(animal[0].toUpperCase(), animal[1], Double.parseDouble(animal[4]), animal[3]);
44 | }
45 | } else {
46 | if (animal[6].equalsIgnoreCase("can fly")) {
47 | obj = new TwoLegCanFly(animal[0].toUpperCase(), animal[1], Double.parseDouble(animal[4]), animal[3]);
48 | } else {
49 | obj = new TwoLegNoFly(animal[0].toUpperCase(), animal[1], Double.parseDouble(animal[4]), animal[3]);
50 | }
51 | }
52 | if (obj != null) {
53 | list.add(obj);
54 | }
55 | }
56 | }
57 | } catch (Exception e) {
58 | System.out.println("Error at File_DAO " + e.toString());
59 | } finally {
60 | try {
61 | if (fr != null) {
62 | fr.close();
63 | }
64 | if (br != null) {
65 | br.close();
66 | }
67 | } catch (Exception e) {
68 | System.out.println("Error at Load data File_DAO close connection " + e.toString());
69 | }
70 | }
71 | return list;
72 | }
73 |
74 | public static void writeData(String filename, TreeSet list) {
75 | PrintWriter pw = null;
76 |
77 | try {
78 | pw = new PrintWriter(filename);
79 | for (Animal a : list) {
80 | pw.println(a.toStringMySelf());
81 | pw.flush();
82 | }
83 |
84 | } catch (Exception e) {
85 | System.out.println("Error at write data File_DAO " + e.toString());
86 | } finally {
87 | try {
88 | if (pw != null) {
89 | pw.close();
90 | }
91 | } catch (Exception e) {
92 | System.out.println("Error at Write data File_DAO close connection " + e.toString());
93 | }
94 | }
95 | }
96 |
97 | }
98 |
--------------------------------------------------------------------------------
/src/data/Animal.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */
6 | package data;
7 |
8 | import validation.Check;
9 |
10 | /**
11 | *
12 | * @author Dell
13 | */
14 | public abstract class Animal implements Comparable {
15 |
16 | public String id;
17 | public String name;
18 | public int leg;
19 | public double weight;
20 | public String characteristic;
21 |
22 | public Animal() {
23 | id = "";
24 | name = "";
25 | leg = 0;
26 | weight = 0;
27 | characteristic = "";
28 | }
29 |
30 | public Animal(String id, String name, int leg, double weight, String characteristic) {
31 | this.id = id;
32 | this.name = name;
33 | this.leg = leg;
34 | this.weight = weight;
35 | this.characteristic = characteristic;
36 | }
37 |
38 | public String getId() {
39 | return id;
40 | }
41 |
42 | public void setId(String id) {
43 | this.id = id;
44 | }
45 |
46 | public String getName() {
47 | return name;
48 | }
49 |
50 | public void setName(String name) {
51 | this.name = name;
52 | }
53 |
54 | public int getLeg() {
55 | return leg;
56 | }
57 |
58 | public void setLeg(int leg) {
59 | this.leg = leg;
60 | }
61 |
62 | public double getWeight() {
63 | return weight;
64 | }
65 |
66 | public void setWeight(double weight) {
67 | this.weight = weight;
68 | }
69 |
70 | public String getCharacteristic() {
71 | return characteristic;
72 | }
73 |
74 | public void setCharacteristic(String characteristic) {
75 | this.characteristic = characteristic;
76 | }
77 |
78 | public abstract void input();
79 |
80 | public abstract void showinfo();
81 |
82 | public abstract String toStringMySelf();
83 |
84 | public void update() {
85 | name = Check.getAName("Enter animal's Name: ", "Name has just alphabet, please !!!");
86 | weight = Check.getADouble("Enter animal'Weight: ",
87 | "Weight's animal is a double number and in 0-2000kg, please !!!", 0, 2000);
88 | characteristic = Check.getAName("Enter animal's Characteristic: ",
89 | "Don't have any special character, please !!!");
90 | }
91 |
92 | @Override
93 | public int compareTo(Animal o) {
94 | return this.id.compareToIgnoreCase(o.id);
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/src/data/AnimalList.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */
6 | package data;
7 |
8 | import dao.File_DAO;
9 | import java.util.TreeSet;
10 | import validation.Check;
11 |
12 | /**
13 | *
14 | * @author Dell
15 | */
16 | public class AnimalList {
17 |
18 | public TreeSet list;
19 |
20 | public AnimalList() {
21 | list = new TreeSet<>();
22 | }
23 |
24 | public AnimalList(TreeSet list) {
25 | this.list = list;
26 | }
27 |
28 | public TreeSet getList() {
29 | return list;
30 | }
31 |
32 | public void setList(TreeSet list) {
33 | this.list = list;
34 | }
35 |
36 | public void loadAnimal(String filename) {
37 | list = File_DAO.loadData(filename);
38 | if (!list.isEmpty()) {
39 | System.out.println("Loading successfully!");
40 | } else {
41 | System.out.println("Nothing to load!");
42 | }
43 | }
44 |
45 | public boolean checkExist(String id) {
46 | boolean check = false;
47 | for (Animal a : list) {
48 | if (a.id.equalsIgnoreCase(id)) {
49 | return true;
50 | }
51 | }
52 | return check;
53 | }
54 |
55 | public Animal getAnimalByID(String id) {
56 | if (!list.isEmpty()) {
57 | for (Animal a : list) {
58 | if (a.id.equalsIgnoreCase(id)) {
59 | return a;
60 | }
61 | }
62 | }
63 | return null;
64 | }
65 |
66 | public boolean addAnimal(Animal a) {
67 | String id;
68 | do {
69 | id = Check.getAnID("Enter animal's ID: ",
70 | "Format ID: aaxxxx, a is alphabet, x is number please !!!");
71 | if (checkExist(id)) {
72 | System.out.println("Sorry, this AnimalID has existed in system !");
73 | }
74 | } while (checkExist(id));
75 | a.setId(id);
76 | if (a instanceof NoLeg) {
77 | a.input();
78 | } else if (a instanceof TwoLegCanFly) {
79 | a.input();
80 | } else if (a instanceof TwoLegNoFly) {
81 | a.input();
82 | } else if (a instanceof FourLeg) {
83 | a.input();
84 | } else {
85 | System.out.println("This type Animal is not supported!");
86 | }
87 | return list.add(a);
88 | }
89 |
90 | public void updateAnimal(String idInput) {
91 | if (!list.isEmpty()) {
92 | for (Animal a : list) {
93 | if (a.id.equalsIgnoreCase(idInput)) {
94 | a.update();
95 | System.out.println("Updating successfully!");
96 | System.out.println(" ID Name Leg Characteristic Weight Swings Fly");
97 | a.showinfo();
98 | return;
99 | }
100 | }
101 | System.out.println("This animal does not exist in list!");
102 | } else {
103 | System.out.println("Nothing to update!");
104 | }
105 | }
106 |
107 | public void deleteAnimal(String idInput) {
108 | int flag = 0;
109 | if (!list.isEmpty()) {
110 |
111 | Animal a = getAnimalByID(idInput);
112 | if (a != null) {
113 | flag = 1;
114 | }
115 |
116 | if (flag == 1) {
117 | String answer = new String();
118 | answer = Check.getAnswer("Are you sure to delete this animal? ",
119 | "Just yes or no answer, please !!!");
120 | if (answer.equalsIgnoreCase("yes")) {
121 | if (list.remove(a)) {
122 | System.out.println("Deleting successfully!");
123 | } else {
124 | System.out.println("Deleting failed!");
125 | }
126 | } else {
127 | System.out.println("OKAY! This animal still exist in list !");
128 | }
129 | } else {
130 | System.out.println("This animal does not exist in list!");
131 | }
132 | } else {
133 | System.out.println("Nothing to delete");
134 | }
135 | }
136 |
137 | public TreeSet searchByName(String nameInput) {
138 | TreeSet tmpList = new TreeSet<>();
139 | for (Animal a : list) {
140 | if (a.name.equalsIgnoreCase(nameInput)) {
141 | tmpList.add(a);
142 | }
143 | }
144 | return tmpList;
145 | }
146 |
147 | public TreeSet searchByWeight(double weightInput) {
148 | TreeSet tmpList = new TreeSet<>();
149 | for (Animal a : list) {
150 | if (a.weight == weightInput) {
151 | tmpList.add(a);
152 | }
153 | }
154 | return tmpList;
155 | }
156 |
157 | public void showNoLeg() {
158 | int flag = 0;
159 | System.out.println(" ID Name Leg Characteristic Weight");
160 | for (Animal o : list) {
161 | if (o instanceof NoLeg) {
162 | o.showinfo();
163 | flag = 1;
164 | }
165 | }
166 | if (flag == 0) {
167 | System.out.println("Don't have any animal no leg in list!");
168 | }
169 | }
170 |
171 | public void showTwoLegNoFly() {
172 | int flag = 0;
173 | System.out.println(" ID Name Leg Characteristic Weight Swings Fly");
174 | for (Animal o : list) {
175 | if (o instanceof TwoLegNoFly) {
176 | o.showinfo();
177 | flag = 1;
178 | }
179 | }
180 | if (flag == 0) {
181 | System.out.println("Don't have any animal bipedal and flightless in list!");
182 | }
183 | }
184 |
185 | public void showTwoLegCanFly() {
186 | int flag = 0;
187 | System.out.println(" ID Name Leg Characteristic Weight Swings Fly");
188 | for (Animal o : list) {
189 | if (o instanceof TwoLegCanFly) {
190 | o.showinfo();
191 | flag = 1;
192 | }
193 | }
194 | if (flag == 0) {
195 | System.out.println("Don't have any animal bipedal and flying in list!");
196 | }
197 | }
198 |
199 | public void showFourLeg() {
200 | int flag = 0;
201 | System.out.println(" ID Name Leg Characteristic Weight");
202 | for (Animal o : list) {
203 | if (o instanceof FourLeg) {
204 | o.showinfo();
205 | flag = 1;
206 | }
207 | }
208 | if (flag == 0) {
209 | System.out.println("Don't have any animal four leg in list!");
210 | }
211 | }
212 |
213 | public void showAll() {
214 | System.out.println(" ID Name Leg Characteristic Weight Swings Fly");
215 | for (Animal a : list) {
216 | a.showinfo();
217 | }
218 | }
219 |
220 | public void showAll(TreeSet tmp) {
221 | System.out.println(" ID Name Leg Characteristic Weight Swings Fly");
222 | for (Animal a : tmp) {
223 | a.showinfo();
224 | }
225 | }
226 |
227 | public void storeAnimal(String filename) {
228 | File_DAO.writeData(filename, list);
229 | }
230 | }
231 |
--------------------------------------------------------------------------------
/src/data/FourLeg.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */
6 | package data;
7 |
8 | import validation.Check;
9 |
10 | /**
11 | *
12 | * @author Dell
13 | */
14 | public class FourLeg extends Animal {
15 |
16 | public FourLeg() {
17 | id = "";
18 | name = "";
19 | leg = 4;
20 | weight = 0;
21 | characteristic = "";
22 | }
23 |
24 | public FourLeg(String id, String name, double weight, String characteristic) {
25 | super(id, name, 4, weight, characteristic);
26 | }
27 |
28 | @Override
29 | public void input() {
30 | name = Check.getAName("Enter animal's Name: ", "Name has just alphabet, please !!!").trim();
31 | weight = Check.getADouble("Enter animal's Weight: ",
32 | "Weight's Animal is a double number and in 0-2000kg, please !!!", 0, 2000);
33 | characteristic = Check.getAName("Enter animal's Characteristic: ",
34 | "Don't have any special character, please !!!").trim();
35 | }
36 |
37 | @Override
38 | public void showinfo() {
39 | String msg = new String();
40 | msg = String.format("|%-10s|%-15s|%5d|%30s|%14.2f|", id, name, leg, characteristic, weight);
41 | System.out.println(msg);
42 | }
43 |
44 | @Override
45 | public String toStringMySelf() {
46 | return id + ";" + name + ";" + leg + ";" + characteristic + ";" + weight;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/data/NoLeg.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */
6 | package data;
7 |
8 | import validation.Check;
9 |
10 | /**
11 | *
12 | * @author Dell
13 | */
14 | public class NoLeg extends Animal {
15 |
16 | public NoLeg() {
17 | super();
18 | }
19 |
20 | public NoLeg(String id, String name, double weight, String characteristic) {
21 | super(id, name, 0, weight, characteristic);
22 | }
23 |
24 | @Override
25 | public void input() {
26 | name = Check.getAName("Enter animal's Name: ", "Name has just alphabet, please !!!").trim();
27 | weight = Check.getADouble("Enter animal's Weight: ",
28 | "Weight's Animal is a double number and in 0-2000kg, please !!!", 0, 2000);
29 | characteristic = Check.getAName("Enter animal's Characteristic: ",
30 | "Don't have any special character, please !!!").trim();
31 | }
32 |
33 | @Override
34 | public void showinfo() {
35 | String msg = new String();
36 | msg = String.format("|%-10s|%-15s|%5d|%30s|%14.2f|", id, name, leg, characteristic, weight);
37 | System.out.println(msg);
38 | }
39 |
40 | @Override
41 | public String toStringMySelf() {
42 | return id + ";" + name + ";" + leg + ";" + characteristic + ";" + weight;
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/src/data/TwoLegCanFly.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */
6 | package data;
7 |
8 | import validation.Check;
9 |
10 | /**
11 | *
12 | * @author Dell
13 | */
14 | public class TwoLegCanFly extends Animal {
15 |
16 | static final String FLY = "Can fly";
17 | public int swings;
18 |
19 | public TwoLegCanFly() {
20 | id = "";
21 | name = "";
22 | leg = 2;
23 | swings = 2;
24 | weight = 0;
25 | characteristic = "";
26 | }
27 |
28 | public TwoLegCanFly(String id, String name, double weight, String characteristic) {
29 | super(id, name, 2, weight, characteristic);
30 | this.swings = 2;
31 | }
32 |
33 | public int getSwings() {
34 | return swings;
35 | }
36 |
37 | public void setSwings(int swings) {
38 | this.swings = swings;
39 | }
40 |
41 | @Override
42 | public void input() {
43 | name = Check.getAName("Enter animal's Name: ", "Name has just alphabet, please !!!").trim();
44 | weight = Check.getADouble("Enter animal's Weight: ",
45 | "Weight's Animal is a double number and in 0-2000kg, please !!!", 0, 2000);
46 | characteristic = Check.getAName("Enter animal's Characteristic: ",
47 | "Don't have any special character, please !!!").trim();
48 | }
49 |
50 | @Override
51 | public void showinfo() {
52 | String msg = new String();
53 | msg = String.format("|%-10s|%-15s|%5d|%30s|%14.2f|%15d|%10s|",
54 | id, name, leg, characteristic, weight, swings, FLY);
55 | System.out.println(msg);
56 | }
57 |
58 | @Override
59 | public String toStringMySelf() {
60 | return id + ";" + name + ";" + leg + ";" + characteristic + ";" + weight + ";" + swings + ";" + FLY;
61 | }
62 | }
63 |
--------------------------------------------------------------------------------
/src/data/TwoLegNoFly.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */
6 | package data;
7 |
8 | import validation.Check;
9 |
10 | /**
11 | *
12 | * @author Dell
13 | */
14 | public class TwoLegNoFly extends Animal {
15 |
16 | static final String FLY = "No Fly";
17 | public int swings;
18 |
19 | public TwoLegNoFly() {
20 | id = "";
21 | name = "";
22 | leg = 2;
23 | swings = 2;
24 | weight = 0;
25 | characteristic = "";
26 | }
27 |
28 | public TwoLegNoFly(String id, String name, double weight, String characteristic) {
29 | super(id, name, 2, weight, characteristic);
30 | this.swings = 2;
31 | }
32 |
33 | public int getSwings() {
34 | return swings;
35 | }
36 |
37 | public void setSwings(int swings) {
38 | this.swings = swings;
39 | }
40 |
41 | @Override
42 | public void input() {
43 | name = Check.getAName("Enter animal's Name: ", "Name has just alphabet, please !!!").trim();
44 | weight = Check.getADouble("Enter animal's Weight: ",
45 | "Weight's Animal is a double number and in 0-2000kg, please !!!", 0, 2000);
46 | characteristic = Check.getAName("Enter animal's Characteristic: ",
47 | "Don't have any special character, please !!!").trim();
48 | }
49 |
50 | @Override
51 | public void showinfo() {
52 | String msg = new String();
53 | msg = String.format("|%-10s|%-15s|%5d|%30s|%14.2f|%15d|%10s|",
54 | id, name, leg, characteristic, weight, swings, FLY);
55 | System.out.println(msg);
56 | }
57 |
58 | @Override
59 | public String toStringMySelf() {
60 | return id + ";" + name + ";" + leg + ";" + characteristic + ";" + weight + ";" + swings + ";" + FLY;
61 | }
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/src/run/Program.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */
6 | package run;
7 |
8 | import data.Animal;
9 | import data.AnimalList;
10 | import data.FourLeg;
11 | import data.NoLeg;
12 | import data.TwoLegCanFly;
13 | import data.TwoLegNoFly;
14 | import java.util.TreeSet;
15 | import validation.Check;
16 |
17 | /**
18 | *
19 | * @author Dell
20 | */
21 | public class Program {
22 |
23 | public static void main(String[] args) {
24 | int choice;
25 | AnimalList obj = new AnimalList();
26 | do {
27 | Menu();
28 | choice = Check.getAnInteger("Your choice is: ",
29 | "Choose 1-8 options please !!!", 1, 8);
30 | switch (choice) {
31 |
32 | case 1: {
33 | obj.loadAnimal("Animal.txt");
34 | if (!obj.getList().isEmpty()) {
35 | obj.showAll();
36 | }
37 | break;
38 | }
39 |
40 | case 2: {
41 | int flag = 1;
42 | do {
43 | MenuAdd();
44 | int choiceIn = Check.getAnInteger("Your choice is: ",
45 | "Choose 1-4 options, please !!!", 1, 4);
46 | switch (choiceIn) {
47 |
48 | case 1: {
49 | NoLeg obj1 = new NoLeg();
50 | if (obj.addAnimal(obj1)) {
51 | System.out.println("Adding successfully!");
52 | } else {
53 | System.out.println("Adding failed! This ID has existed!");
54 | }
55 |
56 | break;
57 | }
58 |
59 | case 2: {
60 | MenuTwoLeg();
61 | choiceIn = Check.getAnInteger("Your choice is: ",
62 | "Just choose 1 in 2 options, please !!!", 1, 2);
63 | switch (choiceIn) {
64 | case 1: {
65 | TwoLegNoFly obj2 = new TwoLegNoFly();
66 | if (obj.addAnimal(obj2)) {
67 | System.out.println("Adding successfully !");
68 | } else {
69 | System.out.println("Adding failed! This ID has existed!");
70 | }
71 | break;
72 | }
73 |
74 | case 2: {
75 | TwoLegCanFly obj3 = new TwoLegCanFly();
76 | if (obj.addAnimal(obj3)) {
77 | System.out.println("Adding successfully !");
78 | } else {
79 | System.out.println("Adding failed! This ID has existed!");
80 | }
81 | break;
82 | }
83 | }
84 |
85 | break;
86 | }
87 |
88 | case 3: {
89 | FourLeg obj4 = new FourLeg();
90 | if (obj.addAnimal(obj4)) {
91 | System.out.println("Adding successfully !");
92 | } else {
93 | System.out.println("Adding failed! This ID has existed!");
94 | }
95 | break;
96 | }
97 | }
98 | String answer = new String();
99 | answer = Check.getAnswer("Do you wanna continue to add animal ? ",
100 | "Just yes or no answer, please !!!");
101 | if (answer.equalsIgnoreCase("yes")) {
102 | flag = 1;
103 | } else {
104 | flag = 0;
105 | }
106 | } while (flag == 1);
107 |
108 | break;
109 | }
110 |
111 | case 3: {
112 | String idInput = new String();
113 | idInput = Check.getAnID("Enter animal's ID you wanna update: ",
114 | "Format ID: aaxxxx, a is alphabet, x is number please !!!");
115 | obj.updateAnimal(idInput);
116 | break;
117 | }
118 |
119 | case 4: {
120 | String idInput = new String();
121 | idInput = Check.getAnID("Enter animal's ID you wanna delete: ",
122 | "Format ID: aaxxxx, a is alphabet, x is number please !!!");
123 | obj.deleteAnimal(idInput);
124 | break;
125 | }
126 |
127 | case 5: {
128 | Menu5();
129 | int choiceIn = Check.getAnInteger("Your choice is: ",
130 | "Just choose 1 in 2 options, please !!!", 1, 2);
131 | switch (choiceIn) {
132 | case 1: {
133 | if (obj.getList().isEmpty()) {
134 | System.out.println("Nothing in list!");
135 | } else {
136 | TreeSet tmpList = new TreeSet<>();
137 | String nameInput = new String();
138 | nameInput = Check.getAName("Enter animal's Name you wanna search: ",
139 | "Name's Animal is not empty, please !!!");
140 | tmpList = obj.searchByName(nameInput);
141 | if (!tmpList.isEmpty()) {
142 | obj.showAll(tmpList);
143 | } else {
144 | System.out.println("Can't find this animal!");
145 | }
146 | }
147 | break;
148 | }
149 |
150 | case 2: {
151 | if (obj.getList().isEmpty()) {
152 | System.out.println("Nothing in list!");
153 | } else {
154 | double weightInput;
155 | weightInput = Check.getADouble("Enter animal's weight you wanna search: ",
156 | "Weight's animal is a double number and in 0-2000kg, please !!!", 0, 2000);
157 | TreeSet result = new TreeSet<>();
158 | result = obj.searchByWeight(weightInput);
159 | if (result.isEmpty()) {
160 | System.out.println("Can't find any animal!");
161 | } else {
162 | obj.showAll(result);
163 | }
164 | }
165 | break;
166 | }
167 | }
168 | break;
169 | }
170 |
171 | case 6: {
172 | if (obj.getList().isEmpty()) {
173 | System.out.println("Nothing in list");
174 | } else {
175 | Menu6();
176 | int choiceIn = Check.getAnInteger("Your choice is: ",
177 | "Just choose 1 in 2 options, please !!!", 1, 2);
178 | switch (choiceIn) {
179 | case 1: {
180 | MenuTypeAnimal();
181 | choice = Check.getAnInteger("Your choice is: ",
182 | "Just choose 1-4 options, please !!!", 1, 4);
183 | switch (choice) {
184 | case 1: {
185 | obj.showNoLeg();
186 | break;
187 | }
188 | case 2: {
189 | obj.showTwoLegNoFly();
190 | break;
191 | }
192 | case 3: {
193 | obj.showTwoLegCanFly();
194 | break;
195 | }
196 | case 4: {
197 | obj.showFourLeg();
198 | break;
199 | }
200 | }
201 | break;
202 | }
203 |
204 | case 2: {
205 | obj.showAll();
206 | break;
207 | }
208 | }
209 | }
210 |
211 | break;
212 | }
213 |
214 | case 7: {
215 | obj.storeAnimal("Animal.txt");
216 | break;
217 | }
218 |
219 | case 8: {
220 | System.out.println("Good bye!");
221 | break;
222 | }
223 |
224 | }
225 | } while (choice != 8);
226 | }
227 |
228 | public static void Menu() {
229 | System.out.println("1. Load data from file");
230 | System.out.println("2. Add a new animal");
231 | System.out.println("3. Update an animal");
232 | System.out.println("4. Delete an animal");
233 | System.out.println("5. Search animal");
234 | System.out.println("6. Show animal list");
235 | System.out.println("7. Store data to file");
236 | System.out.println("8. Quit");
237 | }
238 |
239 | public static void MenuAdd() {
240 | System.out.println("Group 1: No leg");
241 | System.out.println("Group 2: Two legs");
242 | System.out.println("Group 3: Four legs");
243 | }
244 |
245 | public static void MenuTwoLeg() {
246 | System.out.println("1. No Fly");
247 | System.out.println("2. Fly");
248 | }
249 |
250 | public static void Menu5() {
251 | System.out.println("1. Search by name");
252 | System.out.println("2. Search by weight");
253 | }
254 |
255 | public static void Menu6() {
256 | System.out.println("1. Show by type");
257 | System.out.println("2. Show all animal");
258 | }
259 |
260 | public static void MenuTypeAnimal() {
261 | System.out.println("Group 1: No leg");
262 | System.out.println("Group 2: Two legs - No fly");
263 | System.out.println("Group 3: Two legs - Can fly");
264 | System.out.println("Group 4: Four legs");
265 | }
266 | }
267 |
--------------------------------------------------------------------------------
/src/validation/Check.java:
--------------------------------------------------------------------------------
1 | /*
2 | * To change this license header, choose License Headers in Project Properties.
3 | * To change this template file, choose Tools | Templates
4 | * and open the template in the editor.
5 | */
6 | package validation;
7 |
8 | import java.util.Scanner;
9 |
10 | /**
11 | *
12 | * @author Dell
13 | */
14 | public class Check {
15 |
16 | static Scanner scan = new Scanner(System.in);
17 |
18 | public static int getAnInteger(String msg, String errorMsg, int min, int max) {
19 | int number;
20 | if (min > max) {
21 | int t = min;
22 | min = max;
23 | max = t;
24 | }
25 |
26 | while (true) {
27 | try {
28 | System.out.println(msg);
29 | number = Integer.parseInt(scan.nextLine());
30 | if (!(number >= min && number <= max)) {
31 | throw new Exception();
32 | }
33 | return number;
34 | } catch (Exception e) {
35 | System.out.println(errorMsg);
36 | }
37 | }
38 | }
39 |
40 | public static String getAName(String msg, String errorMsg) {
41 | String name = new String();
42 | String pattern = "[a-zA-Z].+";
43 | while (true) {
44 | try {
45 | System.out.println(msg);
46 | name = scan.nextLine();
47 | if (!name.matches(pattern)) {
48 | throw new Exception();
49 | }
50 | return toUpperFirstCharacter(name);
51 | } catch (Exception e) {
52 | System.out.println(errorMsg);
53 | }
54 | }
55 | }
56 |
57 | public static String getACharacteristic(String msg, String errorMsg) {
58 | String str = new String();
59 | while (true) {
60 | try {
61 | System.out.println(msg);
62 | str = scan.nextLine();
63 | if (str.isEmpty()) {
64 | throw new Exception();
65 | }
66 | return toUpperFirstCharacter(str);
67 | } catch (Exception e) {
68 | System.out.println(errorMsg);
69 | }
70 | }
71 | }
72 |
73 | public static String getAnID(String msg, String errorMsg) {
74 | String id = new String();
75 | String pattern = "[a-zA-Z]{2}[0-9]{4}";
76 | while (true) {
77 | try {
78 | System.out.println(msg);
79 | id = scan.nextLine();
80 | if (!id.matches(pattern)) {
81 | throw new Exception();
82 | }
83 | return id.toUpperCase();
84 | } catch (Exception e) {
85 | System.out.println(errorMsg);
86 | }
87 | }
88 | }
89 |
90 | public static double getADouble(String msg, String errorMsg, double min, double max) {
91 | double number;
92 | if (min > max) {
93 | double t = min;
94 | min = max;
95 | max = t;
96 | }
97 | while (true) {
98 | try {
99 | System.out.println(msg);
100 | number = Double.parseDouble(scan.nextLine());
101 | if (!(number >= min && number <= max)) {
102 | throw new Exception();
103 | }
104 | return number;
105 | } catch (Exception e) {
106 | System.out.println(errorMsg);
107 | }
108 | }
109 | }
110 |
111 | public static String getAString(String msg, String errorMsg) {
112 | String s = new String();
113 | while (true) {
114 | try {
115 | System.out.println(msg);
116 | s = scan.nextLine();
117 | if (s.isEmpty()) {
118 | throw new Exception();
119 | }
120 | return s;
121 | } catch (Exception e) {
122 | System.out.println(errorMsg);
123 | }
124 | }
125 | }
126 |
127 | public static String getAnswer(String msg, String errorMsg) {
128 | String answer = new String();
129 | while (true) {
130 | try {
131 | System.out.println(msg);
132 | answer = scan.nextLine();
133 | answer = answer.trim();
134 | if (!(answer.equalsIgnoreCase("yes")
135 | || answer.equalsIgnoreCase("no"))) {
136 | throw new Exception();
137 | }
138 | return toUpperFirstCharacter(answer);
139 | } catch (Exception e) {
140 | System.out.println(errorMsg);
141 | }
142 | }
143 | }
144 |
145 | public static String toUpperFirstCharacter(String s) {
146 | String[] stringArr = s.split(" ");
147 | String result = new String();
148 | for (String e : stringArr) {
149 | e = e.toLowerCase();
150 | e = e.substring(0, 1).toUpperCase() + e.substring(1);
151 | result = result.concat(e + " ");
152 | }
153 | return result.trim();
154 | }
155 |
156 | }
157 |
--------------------------------------------------------------------------------