From 6e14f84317da0a976b8ce7e484ee62b3b24f6f2c Mon Sep 17 00:00:00 2001 From: ho30archive Date: Thu, 4 May 2023 14:29:29 +0900 Subject: [PATCH 01/11] feat : set a base --- .idea/.gitignore | 8 + .../me/smartstore/Main.class | Bin 0 -> 520 bytes .../me/smartstore/SmartStoreApp.class | Bin 0 -> 3208 bytes .../me/smartstore/arrays/Collections.class | Bin 0 -> 587 bytes .../me/smartstore/arrays/DArray.class | Bin 0 -> 4394 bytes .../me/smartstore/customer/Customer.class | Bin 0 -> 2845 bytes .../me/smartstore/customer/Customers.class | Bin 0 -> 729 bytes .../exception/ElementNotFoundException.class | Bin 0 -> 999 bytes .../exception/EmptyArrayException.class | Bin 0 -> 984 bytes .../exception/InputEndException.class | Bin 0 -> 540 bytes .../exception/InputRangeException.class | Bin 0 -> 984 bytes .../exception/NullArgumentException.class | Bin 0 -> 990 bytes .../me/smartstore/group/Group.class | Bin 0 -> 2192 bytes .../me/smartstore/group/GroupType.class | Bin 0 -> 1699 bytes .../me/smartstore/group/Groups.class | Bin 0 -> 1031 bytes .../me/smartstore/group/Parameter.class | Bin 0 -> 2004 bytes .../me/smartstore/menu/CustomerMenu.class | Bin 0 -> 785 bytes .../me/smartstore/menu/GroupMenu.class | Bin 0 -> 3398 bytes .../me/smartstore/menu/MainMenu.class | Bin 0 -> 1510 bytes .../me/smartstore/menu/Menu.class | Bin 0 -> 2123 bytes .../me/smartstore/menu/SummaryMenu.class | Bin 0 -> 803 bytes .../me/smartstore/util/Message.class | Bin 0 -> 891 bytes src/me/smartstore/Main.java | 8 + src/me/smartstore/SmartStoreApp.java | 67 ++++++++ src/me/smartstore/arrays/Collections.java | 15 ++ src/me/smartstore/arrays/DArray.java | 150 ++++++++++++++++++ src/me/smartstore/customer/Customer.java | 90 +++++++++++ src/me/smartstore/customer/Customers.java | 30 ++++ .../exception/ArrayEmptyException.java | 15 ++ .../exception/ElementNotFoundException.java | 22 +++ .../exception/EmptyArrayException.java | 22 +++ .../exception/InputEmptyException.java | 15 ++ .../exception/InputEndException.java | 14 ++ .../exception/InputFormatException.java | 14 ++ .../exception/InputRangeException.java | 22 +++ .../exception/InputTypeException.java | 14 ++ .../exception/NullArgumentException.java | 22 +++ src/me/smartstore/group/Group.java | 53 +++++++ src/me/smartstore/group/GroupType.java | 20 +++ src/me/smartstore/group/Groups.java | 29 ++++ src/me/smartstore/group/Parameter.java | 55 +++++++ src/me/smartstore/menu/CustomerMenu.java | 29 ++++ src/me/smartstore/menu/GroupMenu.java | 81 ++++++++++ src/me/smartstore/menu/MainMenu.java | 42 +++++ src/me/smartstore/menu/Menu.java | 49 ++++++ src/me/smartstore/menu/SummaryMenu.java | 27 ++++ src/me/smartstore/util/Message.java | 13 ++ 47 files changed, 926 insertions(+) create mode 100644 .idea/.gitignore create mode 100644 out/production/KDTBE5_Java_ToyProject/me/smartstore/Main.class create mode 100644 out/production/KDTBE5_Java_ToyProject/me/smartstore/SmartStoreApp.class create mode 100644 out/production/KDTBE5_Java_ToyProject/me/smartstore/arrays/Collections.class create mode 100644 out/production/KDTBE5_Java_ToyProject/me/smartstore/arrays/DArray.class create mode 100644 out/production/KDTBE5_Java_ToyProject/me/smartstore/customer/Customer.class create mode 100644 out/production/KDTBE5_Java_ToyProject/me/smartstore/customer/Customers.class create mode 100644 out/production/KDTBE5_Java_ToyProject/me/smartstore/exception/ElementNotFoundException.class create mode 100644 out/production/KDTBE5_Java_ToyProject/me/smartstore/exception/EmptyArrayException.class create mode 100644 out/production/KDTBE5_Java_ToyProject/me/smartstore/exception/InputEndException.class create mode 100644 out/production/KDTBE5_Java_ToyProject/me/smartstore/exception/InputRangeException.class create mode 100644 out/production/KDTBE5_Java_ToyProject/me/smartstore/exception/NullArgumentException.class create mode 100644 out/production/KDTBE5_Java_ToyProject/me/smartstore/group/Group.class create mode 100644 out/production/KDTBE5_Java_ToyProject/me/smartstore/group/GroupType.class create mode 100644 out/production/KDTBE5_Java_ToyProject/me/smartstore/group/Groups.class create mode 100644 out/production/KDTBE5_Java_ToyProject/me/smartstore/group/Parameter.class create mode 100644 out/production/KDTBE5_Java_ToyProject/me/smartstore/menu/CustomerMenu.class create mode 100644 out/production/KDTBE5_Java_ToyProject/me/smartstore/menu/GroupMenu.class create mode 100644 out/production/KDTBE5_Java_ToyProject/me/smartstore/menu/MainMenu.class create mode 100644 out/production/KDTBE5_Java_ToyProject/me/smartstore/menu/Menu.class create mode 100644 out/production/KDTBE5_Java_ToyProject/me/smartstore/menu/SummaryMenu.class create mode 100644 out/production/KDTBE5_Java_ToyProject/me/smartstore/util/Message.class create mode 100644 src/me/smartstore/Main.java create mode 100644 src/me/smartstore/SmartStoreApp.java create mode 100644 src/me/smartstore/arrays/Collections.java create mode 100644 src/me/smartstore/arrays/DArray.java create mode 100644 src/me/smartstore/customer/Customer.java create mode 100644 src/me/smartstore/customer/Customers.java create mode 100644 src/me/smartstore/exception/ArrayEmptyException.java create mode 100644 src/me/smartstore/exception/ElementNotFoundException.java create mode 100644 src/me/smartstore/exception/EmptyArrayException.java create mode 100644 src/me/smartstore/exception/InputEmptyException.java create mode 100644 src/me/smartstore/exception/InputEndException.java create mode 100644 src/me/smartstore/exception/InputFormatException.java create mode 100644 src/me/smartstore/exception/InputRangeException.java create mode 100644 src/me/smartstore/exception/InputTypeException.java create mode 100644 src/me/smartstore/exception/NullArgumentException.java create mode 100644 src/me/smartstore/group/Group.java create mode 100644 src/me/smartstore/group/GroupType.java create mode 100644 src/me/smartstore/group/Groups.java create mode 100644 src/me/smartstore/group/Parameter.java create mode 100644 src/me/smartstore/menu/CustomerMenu.java create mode 100644 src/me/smartstore/menu/GroupMenu.java create mode 100644 src/me/smartstore/menu/MainMenu.java create mode 100644 src/me/smartstore/menu/Menu.java create mode 100644 src/me/smartstore/menu/SummaryMenu.java create mode 100644 src/me/smartstore/util/Message.java diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 00000000..13566b81 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Editor-based HTTP Client requests +/httpRequests/ +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml diff --git a/out/production/KDTBE5_Java_ToyProject/me/smartstore/Main.class b/out/production/KDTBE5_Java_ToyProject/me/smartstore/Main.class new file mode 100644 index 0000000000000000000000000000000000000000..c40e66fb9a0baebd244a1548468d31dcf3153710 GIT binary patch literal 520 zcmZutO;5r=6r80%p;SRZ{6Ix-;K3d>!I&5m6O*ck8ZMrex~WU(mb8oi%L^J0{s4cJ z@hzGlY7aAgv+vEk-S>~zHvmW2b5KOX!5W$d)(vdf*tD_5P&|=J>Qe@*)9o|l&y#z> zQ1zt}*OPc4(px?lk+SM1As_X5Doy<@=JkWj7#e;oye#Ia&UBIr?}|&+Bd?g4q1n0f zhy0OyBd#JZ(5X~WZZS}wM+<6_r98ztKB z?+OgHdG5_%C_>H9TI>tV)`8jjY&>SDL_%MxOmh`dY`fF_b+d(bb44vOGPTl)!afT0 z&gRR3nKcQ^RC&aVxNz_c_B1)bKl@v34Ol*do7v!d}rpV77 W910>^>a%~iIH+NTbb1oP9O|E1gKJ{| literal 0 HcmV?d00001 diff --git a/out/production/KDTBE5_Java_ToyProject/me/smartstore/SmartStoreApp.class b/out/production/KDTBE5_Java_ToyProject/me/smartstore/SmartStoreApp.class new file mode 100644 index 0000000000000000000000000000000000000000..be06281717d797ca6a03ec884a2b680529f7d3fb GIT binary patch literal 3208 zcma)8YjYD-7=D(NZn|tCgi@f~0-`oW8Yn8-Qly50(H1JL)ruFk>1nbw*^Qe`wc`DX zH$)Nd7sUG)M^Rb^M!!1a_}$@~zr%6V=WMp^Ce1izCVS3%Iq&))4t2Cxg? zG++_-sp!?%?$@wYeh%O^sZMFQ9e2oHpN4)Ml)Xa@7{Hxj9M&+1p)l?WV>pbv!?;Jq zh>CkP9Kn4dC@-AVumblt-~l|SA&R3isu4n{aj(>khER9<57|qr7}Fpy9%VhpG)y2@ zzqg5f{xobrUKU|Qp}>wZ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c1sGKaoPekpaIG zLb-Cy1S*UDxCMK?HN4`(De1z8{9ni_f1;PBp1CF6LrIcGZ<|J(6=~CGn_smu?`|PY r_L3&I23AV5Dlncmm(zJ-4Q%~wOT literal 0 HcmV?d00001 diff --git a/out/production/KDTBE5_Java_ToyProject/me/smartstore/arrays/Collections.class b/out/production/KDTBE5_Java_ToyProject/me/smartstore/arrays/Collections.class new file mode 100644 index 0000000000000000000000000000000000000000..c3eded02eae1550a5c0b4c604f123c83b6a5ff63 GIT binary patch literal 587 zcmZ{hO;3YB5Qg6^6iWT7*w)X3C$n7SXrji8i3y2G4<+8$vJx5!4NDvKr+M%P_@j&i zBt#2d*nMZ7nRj;h`u_L?aD_7yCnioAbQQfz28}x&eM6ZujJW4K&c#}|u}DI9@;sNb z{D#4rMqwiIRYtr)jPFxWQ$@*`d(8^xiNWL^VdX7K0{J?5Df+jttZdF!xUUd?yWX4dp)=#}o}oA|AN-9+x1A%^}mU1c-*5XH2V!F?LXw5uph z)Mc?ihVzAV)k0*s%F|4`BFn^^a({7DwYh48fuTdc39xi}CUk(#E)0sB6z!l#+Csn9 qTco$KQ|n#Qdl=Muztn$u8wYiMNO^mszl~9yACqV0e2AlRg5w`69D39M literal 0 HcmV?d00001 diff --git a/out/production/KDTBE5_Java_ToyProject/me/smartstore/arrays/DArray.class b/out/production/KDTBE5_Java_ToyProject/me/smartstore/arrays/DArray.class new file mode 100644 index 0000000000000000000000000000000000000000..45bfe470769688434eaa62454699169944500aca GIT binary patch literal 4394 zcma)9U2_xH8GhFKSX&Y{*hVClO^hK#$PP-~CUG#B8h^#Dz%+84@)=AxY`q?1g;WoG&l`Ul$SPhgVL=iReft&qrcJleD8ocBHN z^SobY{g3~C@fCnqaVLfl)^xn3UA(Jkw z%frxdErz{nr64Os9cB!JYUO$i8`$iI)lYLfI?5XK`Gv*VH*>2Rv}Fx@=InCKG0M)G zQL39EO2srpjcV1{t!Wszl-n|H7}=6h-pH<8+cFEzw1%F%wNW;ldezhrzO=f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q&~#~p*j*?cZbRRozUZZkN+c+)I8o_}75o_Mbc2DnQQ%(@7OuO_$Pn!$`;>%Qa%{_Y%a)(cTdsqG=`2#pL9*9K=U(Vc z=Wno2dxU2Odi=2K?E1~TUc&1PwseRkTGTkkGs*)GFd!Wv*u`uYq`D^J9<*i;kQITU z4qxVB{1Br)57(kzAS^li4^rNP^!xsYo#Ns;c=D_}X!%rleP%?o?l!_vl${X?2g~VS zGLh|YQS)L_WIj$bn^}hK4E(U`L!I6FCPCg}dEI79c$aawji2B>M&#%G&-8si1~1e9 zjTl%SQ7}rX?PXYkKYF62h?J05dyN?MA<`Guzr{YC-&>D(@ieZ`U{_os3>AWl^p;d! zEF*=K>=1!Fftrc=z+!DRBYP?(WKU{FMJ2~L@avj$3Heno-(k;tapoSr`;f5QP@ zr_C$0m$JZb=*$n8pdSV@VaUVL%mi5x>l*8R#k2J>_2q=I{%3N2w@i+Ux#7t#cqDRe zfBg4&Gj!_O{w?)B;)lxbczJ(>QGD#$mVO_hM;l#n%tI046@8vT4c<<&CwNpZ?D`fF n9d9rm^1-G2lE*6dyV#T7=NO~*d-x@j;#rm;(9QWaf2IEcZ}mFm literal 0 HcmV?d00001 diff --git a/out/production/KDTBE5_Java_ToyProject/me/smartstore/customer/Customer.class b/out/production/KDTBE5_Java_ToyProject/me/smartstore/customer/Customer.class new file mode 100644 index 0000000000000000000000000000000000000000..15c20d4b2c51b2e58427f27ac9b71c3085dfc5f2 GIT binary patch literal 2845 zcma)6+j1L45bcpx7Yo^nuSw+CvBAN*m?(fDF}{$*iEV-H1mq+Hcp1xE_Quk#kyfd4 zQBZsaKLAgDfT|c$seb`inEQ)@GM-O$Ptc&Z*s*Nc*fIE&s0zB!V}B@*1ts=dR_932_-0eDw41VJBUDST zD05|5fm>J9}Ch}tvx{IHVsqX?lgDx){fk5C~8(+HXh5C!E4v3*#|~j z&~zw*$EC9B-VSj_3uo`f0cRuZ(VoTE@~l=FHMg(ZUT{a+kwWn-EF9Zm$Ns=k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?d00001 diff --git a/out/production/KDTBE5_Java_ToyProject/me/smartstore/exception/ElementNotFoundException.class b/out/production/KDTBE5_Java_ToyProject/me/smartstore/exception/ElementNotFoundException.class new file mode 100644 index 0000000000000000000000000000000000000000..d5d73535c265575ab18d995875c6a4446c1fe7e1 GIT binary patch literal 999 zcmb7?&2G~`6ot4I1~o}Y8SIdh$#zrOzf@CHv^IC#X;WqHi9!?NpO&%qOc+S@P= z&9Ojr|Jk{K^)9(o0?mFHtFtV+P<^3%EYs58E++JG~(1P74xZsY&zAHpYARo zM%1=z9h!W{$l&u(%YfpzgCx^|It{t8-P?NfoNwR28tN=fmNtvW(h+#^zfBj|{@c(G zS!}{c&A$ltP^13^|7-|4p-$@3>=nHQul8mT-)K<59a5LxfJKju28|kp3G28^GX^wC z8E{Na_SSj_GgOudYgAv)37x`K63CAYw1~m1cFB5=Dm{SHJ2;%7x(sVj(RvQsEo^g` zQ^Kee_pnJvG1e=wHzHcg)D4Q*x+NmBiin+(^^x2*MRX}**Ry7@mwB6XVK3*sE}Zj} b?mVSirsPK7$5wtD7Y}G;(K*}1ui)Wt3k!nA_ugZ99DdRDxZmF1e9cHtcru=kl0WqeI zUFy)}Z;T8+jkF9Xjyp^;9jMnK_q4mFJx}=H4Q!y!(qw6~cq|=({(rPuVCPR8-(|50 zBenPrI6#el1iowtg4ao1nmwhb;MLw7;wud*xIyaD6R_yE(V$VIFkurnX~uviDFaT( z$=+J8KSyPiutD|poX{y;C4v0dLW>y8YL~1xsL~BMz5dZ0)m2!7iZ*lDeqmd{oDxQ* zxP@)nim_gay%y10rEXEg);}ULtBBYsS?|ehQ$&{{?t0c7_9}0i4(#Q;XN7Z-(p{u< Y%aq*c+vw(}adC%67VWb`{0i>=0*|4!h5!Hn literal 0 HcmV?d00001 diff --git a/out/production/KDTBE5_Java_ToyProject/me/smartstore/exception/InputEndException.class b/out/production/KDTBE5_Java_ToyProject/me/smartstore/exception/InputEndException.class new file mode 100644 index 0000000000000000000000000000000000000000..4bcaee2bebd8d784b4500018121a88d27d849ae0 GIT binary patch literal 540 zcmaKoO;5r=5Qg6cYym+O1rsmU8y^Wh84nmPS`(AXK@9f=Hn^tUlI_;;w>+76@CW## zjMEAlf^iR%nb~)q`S|#Jdk1iVV;l7%4$IiVk&T9pCWCb;l{5o}e5*ZXC|pG|!BF$1 z62l~%2>rk(0cGlbH08mVYnjHYWWhYjn4#;3!i__&O>819T(O*rg^`hRZ`C3(o|<{< zOrN3A@}KxKcLT2G?#O7V=KZv_9f~;S^Q_mFfT28!5fSq#{ndhQkZmrPJ1Tc!_?#6pRDph5*C!!CKq5Y-i8K+05Wb-I5LD%7@` V5t`qs6@m2FLyZ^=`&6C7!54J1dv5>$ literal 0 HcmV?d00001 diff --git a/out/production/KDTBE5_Java_ToyProject/me/smartstore/exception/InputRangeException.class b/out/production/KDTBE5_Java_ToyProject/me/smartstore/exception/InputRangeException.class new file mode 100644 index 0000000000000000000000000000000000000000..268b8484351fd2895ee7b95df4ed5a9b372bc041 GIT binary patch literal 984 zcmb7?&2G~`6ot=jYsS&Rpl`ukSwqyvBhG2ai~GSst@IVcB!A@8GFG?M)bm z=0u=+`0QN3dYgPw0?k1fs}EUpq4Y>zOlhS(NCG)MmpbHmxoDZoFco+{h?Jj3Qk&Ey zTKVd0pk^jaV*fOrW#&xA6ZP)T+OdFlIQT5TNPkKj{?O8kWR?=iTk8<$F2in@9xZQ`@zzqtV@};tF`qijW;0Fs>DmHfOdY${ zp~-iQ46a661{B8~CYcV@`;dFuUDKWyeDMZ0P-khfv{^isjzIrES}m}1)5fzbHeq!0 z9k7oY{So+QLlC@9>eB2by#=rK<`Ca#P{AEim)?LykBtV68ifg)xJxqzG)Wn7LQeM9 zdi^;ntAq`zujhnL;VKE_#}-<|U{n-;tPiA7N*gg`=yx*$;(Sur)E)Zm|JJf^%B zt4J((03Hf)uWdpa!U9`5o*AF{?wM=<`1$QSfaf@H;ot$w4$DK9U6wru`wkunG+u;B zXwC%chesCz)~ob`5@-*?M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gg)taB}5jbn~1AK?x@W{+Iw LJj?mpeBSvF*}vtc literal 0 HcmV?d00001 diff --git a/out/production/KDTBE5_Java_ToyProject/me/smartstore/group/GroupType.class b/out/production/KDTBE5_Java_ToyProject/me/smartstore/group/GroupType.class new file mode 100644 index 0000000000000000000000000000000000000000..c9534c816067514018753268dd5af767eedc9d4d GIT binary patch literal 1699 zcmah}+in|G6kW$2dyXd)dor|vmbSSxZEc6f4Q;u_goNOx0oN&+)L{BFF+*?}+mSu4 z1RsEq;1z)ok$B?SID~R(QJ;D5PqgM25PP4DT31BalGnbReOvn+`>%g~{}aH=xS4>4 zWdm4q`PSC0~wz<$udAWF_;0R3K z9NIO0+x0tMTVOh!86K^zG(V)asba0+l{)n;ueIrJ`Q*`6ne~qZE~fuGQ)cKGcClG? z{j%GtalNpp)^O`oJD#sKYQdsF`jFCVhjinu2OrmnRKlrkH{77pqB2Jh$<9z{s^#tY zZq>We@%@r&IF%kg@Te2G)laUuJK?M{U-iQ=qiHTXKQLIK(W&Q$>|l{@&TyKY7EMy) zl_noQjyb+$6Ip(@vnJld`vNEb_c@ukfQpGr_&@+A(#V*Y!K8@^hBFLP3}+dp8O|}B z#-xDx_t!r^`trB_H=p-+zv3E~$=Bb#`>6Zv!@VCKc6ZtQuG|0Ov6<@cfB&>6`Q%wL zcY#>dZ#Ib35nAn&v-Pc8UNs=%mj~}=#dq87g@Lf}We;X@RmvM5%nQTTGUcUt`f;A3 z-@UPPj41;oiLjDHS4kqPB<)2>+KQ626D4UQ;14Yiu#WTk$%-L?7jPZ|b7W1Em$PvcXS(M^0U_Ok$goyGQwwC=BvHQ?CKJrxji{vp6qHvLW(>YxNA$QzB zl(+$QcJ{;_#Iv@(51Bnr@RN$<&bEq3&;&YFGBAb_aMf|D!KW{U%xuLiO8<`B;}z=p zDqagG4amdX=CVB`euUnG(Is_6sV1wVN=>qwQmWO>GMlJkGftZVlGHgxeJ$Gl812ng za~!an3+Gs%xHz;C!!RI`$Lrw)4^#zU{|{&tdn{_(cks*}3}qhC?4!ywl{p@>pH*g3 zna{=TW6HFYd0Y>36UuyEhPflkJYmJd7?ZQk;rKu2B-?OF4TGd>IGNAV~`WT}Ynjd`5aCT=yd0Ab$i){{n{0b724g literal 0 HcmV?d00001 diff --git a/out/production/KDTBE5_Java_ToyProject/me/smartstore/group/Groups.class b/out/production/KDTBE5_Java_ToyProject/me/smartstore/group/Groups.class new file mode 100644 index 0000000000000000000000000000000000000000..02b22f551fc6e754b9027b9a59569fe4cb24ef8d GIT binary patch literal 1031 zcmaJ<+int36kUfIm;ytKEl`2puwH-?CecKbf+R+xF`@N=ritm(fsQy81~LpLefIY4$Q(gZ@nKKq=t*V=3E`E~y748T2XMKFi8Fchq7*oZLt zNlwGH2sUwD!wrG3>~x+uy%Erj>`TY;^6{nWzO*P2ZJX{>d*DjDMdVt(Fk3R# zaAoV&j_m(ud12Xy0@eKVvc2QJS(!mgBSGJoKz2F{QDGnD(Fv?iNBVk1H>|cT-JwJD z_9e7*9CoAy;aYjWl{gr)562yirC+!!IAn*HT9mx{fd+0-5QH(s2{F zxXXhXIvVmi3Mg^}lSC7pa^s_1VCkUlwP19l-8P;zkIa_KR@0Nk7n}&_T(sZ(Xn?s{ zoAyVD96!)Gez+WgXObrc0namUV$AL^3dUgZ6yhTf0nGD1!Uz_qJT36#!3jd#rwHQ; z7RLnleI$_hguqY4zC(F_3iUGr%uiS|;+v-|C>SDpoWCVz3PhYF2_(lEKsrTkjD{2T$Ip;=|wH!V^*arc-Q?jUYqDO{BQ8 w1WHKz1~!Pv&_)W&KB_#nLN#0^hTC8*+dRj-hL8};e~1gP#+OZEf1h;=;(WTk7OI#!$#3hgb5*tL7cND=_;~ zt4+L@#}(WW7(Wl6$6dV7`3J7cGDFE!($NOnfY`c;S9=Y|O*U<1o*Ukjc+YfOSd!?-Whn@-nS@HBcz&s1Z^+L=s$&12N8nT#W^JEgmG|kp`I~$o&6+C`Xh7S8z4F z)OUnc#;;dvKOmJnuKk5V^;aZo{C|&>aa{WosqHH5TIT;b(%)i+BZDI&7@5f*ku;7e zVFX_4L@lyxZV-40vnU5JI#KH*SJt_5jS#bV9oJb83CvMr3@Ni9{=tHY)P^FR=dv!5 z4d!0uu9W&6=B}ZTTDwWb(t3`J0*EH_X2iqNsNmkfLa26^(MqkLbd<;omKDxt;&w!( f5ULnh49>cN2KyXUKEOwKz~sKkafai!_`m%hlt7x% literal 0 HcmV?d00001 diff --git a/out/production/KDTBE5_Java_ToyProject/me/smartstore/menu/CustomerMenu.class b/out/production/KDTBE5_Java_ToyProject/me/smartstore/menu/CustomerMenu.class new file mode 100644 index 0000000000000000000000000000000000000000..fdb3b8890c25b20fda84448fa3bdf165cbe00e83 GIT binary patch literal 785 zcma)4O>fgc5Pcgvw&OTWYDxh~97KtDG>b#EaB$U(=nH#%sdcNagNdN)07Un=$-5EcyuB{$*}epZ;J!5 z!{ao~#R9B$j|P9*+wC2oO(*JroY8BmY3VX(sG)^rVq8LZNTHsUw_sn;_=rky2JIaf z;n&1haDl!{lm)6_pia3BtPs+`S`??G741tXVBl!&mz~DlP#06&r4K&yA1KlUxD_6|DaRx6h~S literal 0 HcmV?d00001 diff --git a/out/production/KDTBE5_Java_ToyProject/me/smartstore/menu/GroupMenu.class b/out/production/KDTBE5_Java_ToyProject/me/smartstore/menu/GroupMenu.class new file mode 100644 index 0000000000000000000000000000000000000000..5dd13d7067a870595cf7cc523042414c0417eb57 GIT binary patch literal 3398 zcmai1TX!2*75+{nYh+~-8#N@3-K3M$P9?>$3N3}irfK3hiHhvFQR>u`+eA8%Cmzj+ znNey3y+H5f4h0G=G=;W)?N#kcS9xsL>I)D28dyO1&PdoJOEG#lb1r-D^X+f%v(M3I z|GEBG0AI$N{n&=0hS?Oqb1B@Rnsb;}(+{L@9wpVgpy9zJ7LvG_#6w9eD&eoI=HY&P z1K&*ITPb`S-_c+uaY@aWQ#gx?YNUqCNmSMPk_Ib@D{6gNZDOZTKutAHnqa&%1Og3> z6mC~23b?8OJfdMm!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ztk>?h>qe|i04=v zkMdV1j(;H|w0|P59OZSyR&n?#wG=;hzJtN^=bA|8(z}|hjE6tO?k4ukj=xn@D|?$5 z7On2B?5^GTd+65?_Zy=25HXFkapo8;FiJ_rX@C^(AsdRPVd6PRZbpf4j2Mp)g~EL| zu?)-G>vL8>6lJaFRXZjCi%3J3gdg=zfix3-#_`tDO29)m5m@ zlhl31+>s1!LLacqE6|HeHU&T1(9gPg>uqO$O7c#Yo_-Fy{)!8LB`a=eo(b9qZ#zDt9$RcXV2byXMg+ir{@5!<6#jwG<3XXa(~^# zS+%@@H6K~@k^>^LG4ZN%V-qW#WVBNrmftvBU@Yd0x!8KkgqTA3)s!DExY?N@)Uf8DI`Z;ETH)^kR5Vp z?W53BI>fes>4d$g?QVHP_OayE$MP#_VG%WfYDS&MI186?MaQ;<3;4vs%Q&awt}>by zsyMG>M;Z4l%ws`dRAQ&=v7Y1Z2~;+_GLF43ytYidFsO|R zFHm^U^AZd9v1?&P9sR(vW6#28U{NNHy?^-FZ6^X}v+gt; ztHq4SSXbKXi`m_q1hM1iGk9K1n?Nm_TL@N(5%PuV(J7MH~j<#x8e!R?-)%9E12T{ z9OY`5hEA~tWzV5bua&Z3c_>$?c^sYaoLNfl0mbRRV7isJEvHqmOHOObE;}vFo^b}4 zU9T3tMrq{-7z3Q@<7#y(HMIfkKIW@hYMKL_?xXw^bM~15Dt&1EzrIlt^TRtYQ4%jR ztlBCow!xY;8QJ6QA5zli6sY7@C~1+e>#Mjr6n-!gu4+``_5Q#$Q7-=uQ&s00ojI)j E4croFZ~y=R literal 0 HcmV?d00001 diff --git a/out/production/KDTBE5_Java_ToyProject/me/smartstore/menu/Menu.class b/out/production/KDTBE5_Java_ToyProject/me/smartstore/menu/Menu.class new file mode 100644 index 0000000000000000000000000000000000000000..5177169580a6a3d6779f8e6c2ccef3b000f3cbfa GIT binary patch literal 2123 zcmaJ@TUQ%Z6#h;Um=H#w1Z-)eonpBJDA8)Qa#M?-v`N8IC~3WPk{n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yvJs literal 0 HcmV?d00001 diff --git a/out/production/KDTBE5_Java_ToyProject/me/smartstore/menu/SummaryMenu.class b/out/production/KDTBE5_Java_ToyProject/me/smartstore/menu/SummaryMenu.class new file mode 100644 index 0000000000000000000000000000000000000000..bcb7aa3ac9b3b9afd1071c7f4bdd9da846a0c60e GIT binary patch literal 803 zcmah{O>fgc5Pcgvw&S>IFr_J9!3_;KIp8CQ77j&1s+1O_ttwe?*|@9JZEPdkLCP=U z%7;WH5L}V?5&RTj>{zry5m>T!=FNLE&%68m=clg#9%9%)4YzdMHfimeu+Y_U$ADvC z(?HL_T?1Q1t*_&rj{6MFY!*c#o$t$d#^8)1>1CAXS)QcQiwO1j1!J286PfSDSuWy0 zGW6WR|0U{^0gFQ+DF+CD# zSkNnunxBLjgBFQcOsI#+lUW+br(w~seaY*CQ}J3@XknG1`|sbfa1HCEE)?EW#1oI_ zX&6r!^r|7lMin_OPtsf-JG*n|Ktyt|ymT0rrOp!7b1^58x=X)q!3D*a20t60${=Ux zEOERzBQrQjl1wg=b@#>SZ`a#{J#5k$Tc91L*DUscu7`pK+PFf9P1z%26wlgwuy0uT zjGBKA$6tFgxY0Iis9<7WD_2D_xcN8qNS_!t$A*Ap^ z1Zjza+G9(jOXMQ1=yEKcd{Q5yer8HJtVo=nh TRu=>M)qu(-XzC53)o}ASQ{k*- literal 0 HcmV?d00001 diff --git a/out/production/KDTBE5_Java_ToyProject/me/smartstore/util/Message.class b/out/production/KDTBE5_Java_ToyProject/me/smartstore/util/Message.class new file mode 100644 index 0000000000000000000000000000000000000000..8e8789db5726097e9aa36e09a5c40d941009c54e GIT binary patch literal 891 zcmaiy!A{#i5Qb-=C5A!^l(qzDnHCVLD#a3)9(uCCL6K||B?gI8w1jO~v|dNMYt+0N z2OgjgRdr0Uun?5newxoS|Bm zo-$aDF8LMr71txb?~K%=9}E`ub8Q{h?u4sCc(Bf3wd#=^N726qQ5c6w>cIwswW?Z8 z=p^0abWpk;d}Ofxc>Okm2cMo4dO>m+da(KAg!Hsab!4#d_=NURFAgZ`fCeLalTyZ7OABfIOkdL_3)ah%b zq?0j4&&_|_ZP_)U!$iI-};O#HUSE5z?={GL)U_;8zL^)FUX B-9i8W literal 0 HcmV?d00001 diff --git a/src/me/smartstore/Main.java b/src/me/smartstore/Main.java new file mode 100644 index 00000000..542c11bd --- /dev/null +++ b/src/me/smartstore/Main.java @@ -0,0 +1,8 @@ +package me.smartstore; + +public class Main { + public static void main(String[] args) { + SmartStoreApp.getInstance().test() .run(); +// SmartStoreApp.getInstance().run(); + } +} diff --git a/src/me/smartstore/SmartStoreApp.java b/src/me/smartstore/SmartStoreApp.java new file mode 100644 index 00000000..dc4f8817 --- /dev/null +++ b/src/me/smartstore/SmartStoreApp.java @@ -0,0 +1,67 @@ +package me.smartstore; + +import me.smartstore.customer.Customer; +import me.smartstore.customer.Customers; +import me.smartstore.group.Group; +import me.smartstore.group.GroupType; +import me.smartstore.group.Groups; +import me.smartstore.group.Parameter; +import me.smartstore.menu.MainMenu; + + +public class SmartStoreApp { + + private final Groups allGroups = Groups.getInstance(); + private final Customers allCustomers = Customers.getInstance(); + + private final MainMenu mainMenu = MainMenu.getInstance(); + // singleton + private static SmartStoreApp smartStoreApp; + + public static SmartStoreApp getInstance() { + if (smartStoreApp == null) { + smartStoreApp = new SmartStoreApp(); + } + return smartStoreApp; + } + + private SmartStoreApp() {} + + public void details() { + System.out.println("\n\n==========================================="); + System.out.println(" Title : SmartStore Customer Classification"); + System.out.println(" Release Date : 23.04.27"); + System.out.println(" Copyright 2023 Eunbin All rights reserved."); + System.out.println("===========================================\n"); + } + + + public SmartStoreApp test() { + allGroups.add(new Group(new Parameter(10, 100000), GroupType.GENERAL)); + allGroups.add(new Group(new Parameter(20, 200000), GroupType.VIP)); + allGroups.add(new Group(new Parameter(30, 300000), GroupType.VVIP)); + + for (int i = 0; i < 26; i++) { + allCustomers.add(new Customer( + Character.toString( + (char) ('a' + i)), + (char) ('a' + i) + "123", + ((int) (Math.random() * 5) + 1) * 10, + ((int) (Math.random() * 5) + 1) * 100000)); + } + + System.out.println("allCustomers = " + allCustomers); + System.out.println("allGroups = " + allGroups); + + // @TODO: refresh do not implemented yet. + allCustomers.refresh(allGroups); + + return this; // smartStoreApp + } + + public void run() { + details(); + mainMenu.manage(); + + } +} diff --git a/src/me/smartstore/arrays/Collections.java b/src/me/smartstore/arrays/Collections.java new file mode 100644 index 00000000..264adcd3 --- /dev/null +++ b/src/me/smartstore/arrays/Collections.java @@ -0,0 +1,15 @@ +package me.smartstore.arrays; + +public interface Collections { + + int size(); + T get(int index); + void set(int index, T object); + int indexOf(T object); + void add(T object); + void add(int index, T object); + T pop(); + T pop(int index); + T pop(T object); + +} diff --git a/src/me/smartstore/arrays/DArray.java b/src/me/smartstore/arrays/DArray.java new file mode 100644 index 00000000..9e6b51ff --- /dev/null +++ b/src/me/smartstore/arrays/DArray.java @@ -0,0 +1,150 @@ +package me.smartstore.arrays; + +import me.smartstore.exception.ElementNotFoundException; +import me.smartstore.exception.EmptyArrayException; +import me.smartstore.exception.NullArgumentException; + +public class DArray implements Collections{ + + protected static final int DEFAULT = 10; + + protected T[] arrays; + protected int size; + protected int capacity; + + public DArray() throws ClassCastException{ + arrays = (T[]) new Object[DEFAULT]; + capacity = DEFAULT; + } + + public DArray(int initial) throws ClassCastException{ + arrays = (T[]) new Object[initial]; + capacity = initial; + } + + public DArray(T[] arrays){ + this.arrays = arrays; + capacity = arrays.length; + size = arrays.length; + } + ////////////////// + // add, set, get, pop, indexOf, size, capacity (for dynamic-sized array) + + @Override + public int size(){ + return size; + } + + protected int capacity(){ + return capacity; + } + + @Override + public T get(int index) throws IndexOutOfBoundsException{ + if(index<0 || index>=size) throw new IndexOutOfBoundsException(); + return arrays[index]; + } + + /** + * @param: ... + * @return: ... + * @throws: IndexOutOfBoundsException + * @throws: NullArgumentException + * */ + + @Override + public void set(int index, T object) throws IndexOutOfBoundsException, NullPointerException{ + if (index<0 || index>=size) throw new IndexOutOfBoundsException(); + if (object == null) throw new NullPointerException(); + + arrays[index] = object; + } + + @Override + public int indexOf(T object) throws NullPointerException, ElementNotFoundException { + if (object == null) throw new NullPointerException(); + + for (int i = 0; i < size; i++) { + if (arrays[i] == null) continue; + if (arrays[i].equals(object)) return i; + } + throw new ElementNotFoundException(); + } + + @Override + public void add(T object) throws NullPointerException{ + if(object == null) throw new NullPointerException(); + + if(size < capacity){ + arrays[size] = object; + size++; + } else { + grow(); + add(object); + } + } + + @Override + public void add(int index, T object) throws IndexOutOfBoundsException, NullArgumentException { + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + if (object == null) throw new NullArgumentException(); + + if (size < capacity) { + for (int i = size-1; i >= index ; i--) { + arrays[i+1] = arrays[i]; + } + arrays[index] = object; + size++; + } else { + grow(); + add(index, object); + } + } + @Override + public T pop() { +// if (size == 0) return null; +// +// T popElement = arrays[size-1]; +// arrays[size-1] = null; +// size--; +// return popElement; + return pop(size-1); + } + + @Override + public T pop(int index) throws IndexOutOfBoundsException { + if (size == 0) throw new EmptyArrayException(); + if (index < 0 || index >= size) throw new IndexOutOfBoundsException(); + + T popElement = arrays[index]; + arrays[index] = null; // 삭제됨을 명시적으로 표현 + + for (int i = index+1; i < size; i++) { + arrays[i-1] = arrays[i]; + } + arrays[size-1] = null; + size--; + return popElement; + } + + @Override + public T pop(T object) { + return pop(indexOf(object)); + } + + protected void grow() { + capacity *= 2; // doubling + arrays = java.util.Arrays.copyOf(arrays, capacity); + + // size는 그대로 + } + + @Override + public String toString() { + String toStr = ""; + for (int i = 0; i < size; i++) { + toStr += (arrays[i] + "\n"); + } + return toStr; + } +} diff --git a/src/me/smartstore/customer/Customer.java b/src/me/smartstore/customer/Customer.java new file mode 100644 index 00000000..1d1415e8 --- /dev/null +++ b/src/me/smartstore/customer/Customer.java @@ -0,0 +1,90 @@ +package me.smartstore.customer; + +import me.smartstore.group.Group; + +import java.util.Objects; + +public class Customer { + + private String customerName; + private String customerId; + private int customerTotalTime; + private int customerTotalPay; + private Group group; + + public Customer(){ + + } + + public Customer(String customerName) { + this.customerName = customerName; + } + + public Customer(String customerName, String customerId) { + this.customerName = customerName; + this.customerId = customerId; + } + + public Customer(String customerName, String customerId, int customerTotalTime, int customerTotalPay) { + this.customerName = customerName; + this.customerId = customerId; + this.customerTotalTime = customerTotalTime; + this.customerTotalPay = customerTotalPay; + } + + public String getCustomerName() { + return customerName; + } + + public void setCustomerName(String customerName) { + this.customerName = customerName; + } + + public String getCustomerId() { + return customerId; + } + + public void setCustomerId(String customerId) { + this.customerId = customerId; + } + + public int getCustomerTotalTime() { + return customerTotalTime; + } + + public void setCustomerTotalTime(int customerTotalTime) { + this.customerTotalTime = customerTotalTime; + } + + public int getCustomerTotalPay() { + return customerTotalPay; + } + + public void setCustomerTotalPay(int customerTotalPay) { + this.customerTotalPay = customerTotalPay; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Customer customer = (Customer) o; + return Objects.equals(customerId, customer.customerId); + } + + @Override + public int hashCode() { + return Objects.hash(customerId); + } + + @Override + public String toString() { + return "Customer{" + + "customerName='" + customerName + '\'' + + ", customerId='" + customerId + '\'' + + ", customerTotalTime=" + customerTotalTime + + ", customerTotalPay=" + customerTotalPay + + ", group=" + group + + '}'; + } +} diff --git a/src/me/smartstore/customer/Customers.java b/src/me/smartstore/customer/Customers.java new file mode 100644 index 00000000..9d84fbe2 --- /dev/null +++ b/src/me/smartstore/customer/Customers.java @@ -0,0 +1,30 @@ +package me.smartstore.customer; + +import me.smartstore.arrays.DArray; +import me.smartstore.group.Group; +import me.smartstore.group.GroupType; +import me.smartstore.group.Groups; + +import java.lang.reflect.Parameter; + +public class Customers extends DArray { + // singleton + private static Customers allCustomers; + private Customers(){} + + public static Customers getInstance(){ + if(allCustomers == null){ + allCustomers = new Customers(); + } + return allCustomers; + } + + // refresh 함수가 호출되는 경우 + // 1. 분류기준 바뀔 때 + // 2. 새로운 고객이 들어올 때 + // 해당부분 완성 - SmartStoreApp 참고 + public void refresh(Groups groups){ + + } + +} diff --git a/src/me/smartstore/exception/ArrayEmptyException.java b/src/me/smartstore/exception/ArrayEmptyException.java new file mode 100644 index 00000000..1ab4d480 --- /dev/null +++ b/src/me/smartstore/exception/ArrayEmptyException.java @@ -0,0 +1,15 @@ +package me.smartstore.exception; + + +import me.smartstore.util.Message; + +public class ArrayEmptyException extends RuntimeException { + + public ArrayEmptyException() { + super(Message.ERR_MSG_INVALID_ARR_EMPTY); + } + + public ArrayEmptyException(String message) { + super(message); + } +} diff --git a/src/me/smartstore/exception/ElementNotFoundException.java b/src/me/smartstore/exception/ElementNotFoundException.java new file mode 100644 index 00000000..6e934998 --- /dev/null +++ b/src/me/smartstore/exception/ElementNotFoundException.java @@ -0,0 +1,22 @@ +package me.smartstore.exception; + +public class ElementNotFoundException extends RuntimeException { + public ElementNotFoundException() { + } + + public ElementNotFoundException(String message) { + super(message); + } + + public ElementNotFoundException(String message, Throwable cause) { + super(message, cause); + } + + public ElementNotFoundException(Throwable cause) { + super(cause); + } + + public ElementNotFoundException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } +} diff --git a/src/me/smartstore/exception/EmptyArrayException.java b/src/me/smartstore/exception/EmptyArrayException.java new file mode 100644 index 00000000..b19aeac3 --- /dev/null +++ b/src/me/smartstore/exception/EmptyArrayException.java @@ -0,0 +1,22 @@ +package me.smartstore.exception; + +public class EmptyArrayException extends RuntimeException { + public EmptyArrayException() { + } + + public EmptyArrayException(String message) { + super(message); + } + + public EmptyArrayException(String message, Throwable cause) { + super(message, cause); + } + + public EmptyArrayException(Throwable cause) { + super(cause); + } + + public EmptyArrayException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } +} diff --git a/src/me/smartstore/exception/InputEmptyException.java b/src/me/smartstore/exception/InputEmptyException.java new file mode 100644 index 00000000..93163bc6 --- /dev/null +++ b/src/me/smartstore/exception/InputEmptyException.java @@ -0,0 +1,15 @@ +package me.smartstore.exception; + + +import me.smartstore.util.Message; + +public class InputEmptyException extends RuntimeException { + + public InputEmptyException() { + super(Message.ERR_MSG_INVALID_INPUT_EMPTY); + } + + public InputEmptyException(String message) { + super(message); + } +} diff --git a/src/me/smartstore/exception/InputEndException.java b/src/me/smartstore/exception/InputEndException.java new file mode 100644 index 00000000..f549a39e --- /dev/null +++ b/src/me/smartstore/exception/InputEndException.java @@ -0,0 +1,14 @@ +package me.smartstore.exception; + + +import me.smartstore.util.Message; + +public class InputEndException extends RuntimeException { + public InputEndException() { + super(Message.ERR_MSG_INPUT_END); + } + + public InputEndException(String message) { + super(message); + } +} diff --git a/src/me/smartstore/exception/InputFormatException.java b/src/me/smartstore/exception/InputFormatException.java new file mode 100644 index 00000000..84faad3c --- /dev/null +++ b/src/me/smartstore/exception/InputFormatException.java @@ -0,0 +1,14 @@ +package me.smartstore.exception; + + +import me.smartstore.util.Message; + +public class InputFormatException extends RuntimeException { + public InputFormatException() { + super(Message.ERR_MSG_INVALID_INPUT_FORMAT); + } + + public InputFormatException(String message) { + super(message); + } +} diff --git a/src/me/smartstore/exception/InputRangeException.java b/src/me/smartstore/exception/InputRangeException.java new file mode 100644 index 00000000..19f2e537 --- /dev/null +++ b/src/me/smartstore/exception/InputRangeException.java @@ -0,0 +1,22 @@ +package me.smartstore.exception; + +public class InputRangeException extends RuntimeException { + public InputRangeException() { + } + + public InputRangeException(String message) { + super(message); + } + + public InputRangeException(String message, Throwable cause) { + super(message, cause); + } + + public InputRangeException(Throwable cause) { + super(cause); + } + + public InputRangeException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } +} diff --git a/src/me/smartstore/exception/InputTypeException.java b/src/me/smartstore/exception/InputTypeException.java new file mode 100644 index 00000000..d321992f --- /dev/null +++ b/src/me/smartstore/exception/InputTypeException.java @@ -0,0 +1,14 @@ +package me.smartstore.exception; + + +import me.smartstore.util.Message; + +public class InputTypeException extends RuntimeException { + public InputTypeException() { + super(Message.ERR_MSG_INVALID_INPUT_TYPE); + } + + public InputTypeException(String message) { + super(message); + } +} diff --git a/src/me/smartstore/exception/NullArgumentException.java b/src/me/smartstore/exception/NullArgumentException.java new file mode 100644 index 00000000..e2a8531d --- /dev/null +++ b/src/me/smartstore/exception/NullArgumentException.java @@ -0,0 +1,22 @@ +package me.smartstore.exception; + +public class NullArgumentException extends RuntimeException { + public NullArgumentException() { + } + + public NullArgumentException(String message) { + super(message); + } + + public NullArgumentException(String message, Throwable cause) { + super(message, cause); + } + + public NullArgumentException(Throwable cause) { + super(cause); + } + + public NullArgumentException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } +} diff --git a/src/me/smartstore/group/Group.java b/src/me/smartstore/group/Group.java new file mode 100644 index 00000000..e80f33b3 --- /dev/null +++ b/src/me/smartstore/group/Group.java @@ -0,0 +1,53 @@ +package me.smartstore.group; + +import java.util.Objects; + +public class Group { + private Parameter parameter; + private GroupType groupType; + + public Group() { + } + + public Group(Parameter parameter, GroupType groupType) { + this.parameter = parameter; + this.groupType = groupType; + } + + public Parameter getParameter() { + return parameter; + } + + public void setParameter(Parameter parameter) { + this.parameter = parameter; + } + + public GroupType getGroupType() { + return groupType; + } + + public void setGroupType(GroupType groupType) { + this.groupType = groupType; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Group group = (Group) o; + return Objects.equals(parameter, group.parameter) && groupType == group.groupType; + } + + @Override + public int hashCode() { + return Objects.hash(parameter, groupType); + } + + @Override + public String toString() { + return "Group{" + + "parameter=" + parameter + + ", groupType=" + groupType + + '}'; + } +} diff --git a/src/me/smartstore/group/GroupType.java b/src/me/smartstore/group/GroupType.java new file mode 100644 index 00000000..8d06a90e --- /dev/null +++ b/src/me/smartstore/group/GroupType.java @@ -0,0 +1,20 @@ +package me.smartstore.group; + +public enum GroupType { + NONE("해당없음"), GENERAL("일반고객"), VIP("우수고객"), VVIP("최우수고객"), + N("해당없음"), G("일반고객"), V("우수고객"), VV("최우수고객"); + + String groupType = ""; + + GroupType(String groupType) { + this.groupType = groupType; + } + + public GroupType replaceFullName(){ + if(this == N) return NONE; + else if (this == G) return GENERAL; + else if (this == V) return VIP; + else if (this == VV) return VVIP; + return this; + } +} diff --git a/src/me/smartstore/group/Groups.java b/src/me/smartstore/group/Groups.java new file mode 100644 index 00000000..21ceb7e1 --- /dev/null +++ b/src/me/smartstore/group/Groups.java @@ -0,0 +1,29 @@ +package me.smartstore.group; + +import me.smartstore.arrays.DArray; + +public class Groups extends DArray { + //singleton + private static Groups allGroups; + + private Groups() { + } + + public static Groups getInstance(){ + if(allGroups == null){ + allGroups = new Groups(); + } + return allGroups; + } + + public Group find(GroupType groupType){ + for (Group group : arrays){ + if(group.getGroupType() == groupType){ + return group; + } + } + return null; + } + + +} diff --git a/src/me/smartstore/group/Parameter.java b/src/me/smartstore/group/Parameter.java new file mode 100644 index 00000000..4aab14c7 --- /dev/null +++ b/src/me/smartstore/group/Parameter.java @@ -0,0 +1,55 @@ +package me.smartstore.group; + +import java.security.PrivilegedAction; +import java.util.Objects; + +public class Parameter { + private Integer minTime; + private Integer minPay; + + public Parameter(){ + + } + + public Parameter(Integer minTime, Integer minPay) { + this.minTime = minTime; + this.minPay = minPay; + } + + public Integer getMinTime() { + return minTime; + } + + public void setMinTime(Integer minTime) { + this.minTime = minTime; + } + + public Integer getMinPay() { + return minPay; + } + + public void setMinPay(Integer minPay) { + this.minPay = minPay; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Parameter parameter = (Parameter) o; + return Objects.equals(minTime, parameter.minTime) && Objects.equals(minPay, parameter.minPay); + } + + @Override + public int hashCode() { + return Objects.hash(minTime, minPay); + } + + @Override + public String toString() { + return "Parameter{" + + "minTime=" + minTime + + ", minPay=" + minPay + + '}'; + } +} diff --git a/src/me/smartstore/menu/CustomerMenu.java b/src/me/smartstore/menu/CustomerMenu.java new file mode 100644 index 00000000..a520c007 --- /dev/null +++ b/src/me/smartstore/menu/CustomerMenu.java @@ -0,0 +1,29 @@ +package me.smartstore.menu; + +import me.smartstore.group.Groups; + +public class CustomerMenu implements Menu{ + // singleton + private static CustomerMenu customerMenu; + + public static CustomerMenu getInstance() { + if (customerMenu == null) { + customerMenu = new CustomerMenu(); + } + return customerMenu; + } + + private CustomerMenu() {} + + @Override + public void manage() { + while ( true ) { // 서브 메뉴 페이지를 유지하기 위한 while + int choice = chooseMenu(new String[]{ + "Add Customer", + "View Customer", + "Update Customer", + "Delete Customer", + "Back"}); + } + } +} diff --git a/src/me/smartstore/menu/GroupMenu.java b/src/me/smartstore/menu/GroupMenu.java new file mode 100644 index 00000000..37cb17e3 --- /dev/null +++ b/src/me/smartstore/menu/GroupMenu.java @@ -0,0 +1,81 @@ +package me.smartstore.menu; + +import me.smartstore.customer.Customers; +import me.smartstore.exception.InputEndException; +import me.smartstore.group.Group; +import me.smartstore.group.GroupType; +import me.smartstore.group.Groups; +import me.smartstore.group.Parameter; +import me.smartstore.util.Message; + + +public class GroupMenu implements Menu{ + private final Groups allGroups = Groups.getInstance(); + private final Customers allCustomers = Customers.getInstance(); + // singleton + private static GroupMenu groupMenu; + + public static GroupMenu getInstance() { + if (groupMenu == null) { + groupMenu = new GroupMenu(); + } + return groupMenu; + } + + private GroupMenu() {} + + @Override + public void manage() { + while ( true ) { // 서브 메뉴 페이지를 유지하기 위한 while + int choice = chooseMenu(new String[]{ + "Set Parameter", + "View Parameter", + "Update Parameter", + "Back"}); + + if (choice == 1) setParameter(); + else if (choice == 2) {}// viewParameter(); + else if (choice == 3) {}// updateParameter(); + else break; // choice == 4 + } + + } + + public GroupType chooseGroup() { + while ( true ) { + try { + System.out.print("Which group (GENERAL (G), VIP (V), VVIP (VV))? "); + String choice = nextLine(Message.END_MSG); + // group (str) -> GroupType (enum) + // "VIP" -> GroupType.VIP + + GroupType groupType = GroupType.valueOf(choice).replaceFullName(); + return groupType; + } catch (InputEndException e) { + System.out.println(Message.ERR_MSG_INPUT_END); + return null; + } catch (IllegalArgumentException e) { + System.out.println(Message.ERR_MSG_INVALID_INPUT_RANGE); + } + } + } + + public void setParameter() { // 초기화할 때만 호출 가능 + while ( true ) { + GroupType groupType = chooseGroup(); + + // GroupType에 해당하는 group 객체를 찾아야 함 + Group group = allGroups.find(groupType); + if (group != null && group.getParameter() != null) { // group.getParameter()이 null이 아니면 이미 초기화됨 + System.out.println("\n" + group.getGroupType() + " group already exists."); + System.out.println("\n" + group); + } else { + Parameter parameter = new Parameter(); + // time, pay 사용자 입력받은 후, 설정 필요 + + group.setParameter(parameter); + allCustomers.refresh(allGroups); // 파라미터가 변경되었거나 추가되는 경우, 고객 분류를 다시 해야함 + } + } + } +} diff --git a/src/me/smartstore/menu/MainMenu.java b/src/me/smartstore/menu/MainMenu.java new file mode 100644 index 00000000..a166608d --- /dev/null +++ b/src/me/smartstore/menu/MainMenu.java @@ -0,0 +1,42 @@ +package me.smartstore.menu; + +import me.smartstore.group.Groups; + +public class MainMenu implements Menu{ + private final CustomerMenu customerMenu = CustomerMenu.getInstance(); + private final GroupMenu groupMenu = GroupMenu.getInstance(); + private final SummaryMenu summaryMenu = SummaryMenu.getInstance(); + + // singleton + private static MainMenu mainMenu; + + public static MainMenu getInstance() { + if (mainMenu == null) { + mainMenu = new MainMenu(); + } + return mainMenu; + } + + private MainMenu() {} + + + @Override + public void manage() { + while ( true ) { // 프로그램 실행 while + int choice = mainMenu.chooseMenu(new String[] { + "Parameter", + "Customer", + "Classification Summary", + "Quit"}); + + if (choice == 1) groupMenu.manage(); + else if (choice == 2) customerMenu.manage(); + else if (choice == 3) summaryMenu.manage(); + else { // choice == 4 + System.out.println("Program Finished"); + break; + } + } + + } +} diff --git a/src/me/smartstore/menu/Menu.java b/src/me/smartstore/menu/Menu.java new file mode 100644 index 00000000..4a318760 --- /dev/null +++ b/src/me/smartstore/menu/Menu.java @@ -0,0 +1,49 @@ +package me.smartstore.menu; + +import me.smartstore.exception.InputEndException; +import me.smartstore.exception.InputRangeException; +import me.smartstore.util.Message; + +import java.util.InputMismatchException; +import java.util.Scanner; + +public interface Menu { + Scanner scanner = new Scanner(System.in); + + default String nextLine(){ + return scanner.nextLine().toUpperCase(); + } + + default String nextLine(String end){ + System.out.println("** Press 'end', if you want to exit! **"); + String str = scanner.nextLine().toUpperCase(); + if (str.equals(end)) throw new InputEndException(); + return str; + } + + default int chooseMenu(String[] menus) { + while ( true ) { // 예외 복구 while + try { + System.out.println("==============================="); + for (int i = 0; i < menus.length; i++) { + System.out.printf(" %d. %s\n", i + 1, menus[i]); + } + System.out.println("==============================="); + System.out.print("Choose One: "); + int choice = Integer.parseInt(nextLine()); + if (choice >= 1 && choice <= menus.length) return choice; + throw new InputRangeException(); // choice 가 범위에 벗어남 + + } catch (InputMismatchException e) { + System.out.println(Message.ERR_MSG_INVALID_INPUT_FORMAT); + + } catch (InputRangeException e) { + System.out.println(Message.ERR_MSG_INVALID_INPUT_RANGE); + + } + } + } + + void manage(); // 각 서브메뉴들을 관리하는 함수 (각 서브메뉴의 최상위 메뉴) + +} diff --git a/src/me/smartstore/menu/SummaryMenu.java b/src/me/smartstore/menu/SummaryMenu.java new file mode 100644 index 00000000..b3cea5d1 --- /dev/null +++ b/src/me/smartstore/menu/SummaryMenu.java @@ -0,0 +1,27 @@ +package me.smartstore.menu; + +public class SummaryMenu implements Menu{ + // singleton + private static SummaryMenu summaryMenu; + + public static SummaryMenu getInstance() { + if (summaryMenu == null) { + summaryMenu = new SummaryMenu(); + } + return summaryMenu; + } + + private SummaryMenu() {} + + @Override + public void manage() { + while ( true ) { // 서브 메뉴 페이지를 유지하기 위한 while + int choice = chooseMenu(new String[]{ + "Summary", + "Summary (Sorted By Name)", + "Summary (Sorted By Time)", + "Summary (Sorted By Pay)", + "Back"}); + } + } +} diff --git a/src/me/smartstore/util/Message.java b/src/me/smartstore/util/Message.java new file mode 100644 index 00000000..1c67d21e --- /dev/null +++ b/src/me/smartstore/util/Message.java @@ -0,0 +1,13 @@ +package me.smartstore.util; + +public interface Message { + String ERR_MSG_INVALID_ARR_EMPTY = "No Customers. Please input one first."; + String ERR_MSG_NULL_ARR_ELEMENT = "Elements in Array has null. Array can't be sorted."; + String ERR_MSG_INVALID_INPUT_NULL = "Null Input. Please input something."; + String ERR_MSG_INVALID_INPUT_EMPTY = "Empty Input. Please input something."; + String ERR_MSG_INVALID_INPUT_RANGE = "Invalid Input. Please try again."; + String ERR_MSG_INVALID_INPUT_TYPE = "Invalid Type for Input. Please try again."; + String ERR_MSG_INVALID_INPUT_FORMAT = "Invalid Format for Input. Please try again."; + String ERR_MSG_INPUT_END = "END is pressed. Exit this menu."; + String END_MSG = "END"; +} From 3150755de5567140df64541031499d1476f41849 Mon Sep 17 00:00:00 2001 From: ho30archive Date: Thu, 4 May 2023 17:34:57 +0900 Subject: [PATCH 02/11] feat : add refresh() --- src/me/smartstore/customer/Customers.java | 32 +++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/me/smartstore/customer/Customers.java b/src/me/smartstore/customer/Customers.java index 9d84fbe2..27437210 100644 --- a/src/me/smartstore/customer/Customers.java +++ b/src/me/smartstore/customer/Customers.java @@ -8,6 +8,7 @@ import java.lang.reflect.Parameter; public class Customers extends DArray { + private final Groups allGroups = Groups.getInstance(); // singleton private static Customers allCustomers; private Customers(){} @@ -24,7 +25,38 @@ public static Customers getInstance(){ // 2. 새로운 고객이 들어올 때 // 해당부분 완성 - SmartStoreApp 참고 public void refresh(Groups groups){ + // 고객들 리스트 불러와서 한명씩 Customer.customerTotalTime-Group.minTime + // Customer.customerTotalPay-Group.minPay와 비교를해서 그룹타입을 지정해준다. + // 지정은 setGroup을 통해서 한다. + int generalNum = 0; + int vipNum = 0; + int vvipNum = 0; + for (int i = 0; i < groups.size(); i++) { + if (groups.get(i).getGroupType().equals(GroupType.GENERAL)){ + generalNum = i; + } else if (groups.get(i).getGroupType().equals(GroupType.VIP)) { + vipNum = i; + } else if (groups.get(i).getGroupType().equals(GroupType.VVIP)) { + vvipNum = i; + } + } + + for (int i = 0; i < allCustomers.size; i++) { + if ((allCustomers.get(i).getCustomerTotalTime() Date: Thu, 4 May 2023 19:20:28 +0900 Subject: [PATCH 03/11] fix : fix find(GroupType groupType) --- src/me/smartstore/group/Groups.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/me/smartstore/group/Groups.java b/src/me/smartstore/group/Groups.java index 21ceb7e1..e18729a0 100644 --- a/src/me/smartstore/group/Groups.java +++ b/src/me/smartstore/group/Groups.java @@ -9,17 +9,17 @@ public class Groups extends DArray { private Groups() { } - public static Groups getInstance(){ - if(allGroups == null){ + public static Groups getInstance() { + if (allGroups == null) { allGroups = new Groups(); } return allGroups; } - public Group find(GroupType groupType){ - for (Group group : arrays){ - if(group.getGroupType() == groupType){ - return group; + public Group find(GroupType groupType) { + for (int i = 0; i < this.size; i++) { + if (this.get(i).getGroupType() == groupType) { + return this.get(i); } } return null; From 6875bff0177a48c60ecc67f7a0e38ccc386fa8d2 Mon Sep 17 00:00:00 2001 From: ho30archive Date: Tue, 9 May 2023 19:07:06 +0900 Subject: [PATCH 04/11] feat : set groupMenu MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 기초적인 부분 완성, 파라미터값이 없는 경우 update메뉴 접근 안되는것, 다른 입력값(한글? 이였나 문자열)이 들어간 경우 에러나는것 고쳐야함 --- .../me/smartstore/SmartStoreApp.class | Bin 3208 -> 3292 bytes .../me/smartstore/customer/Customer.class | Bin 2845 -> 3069 bytes .../me/smartstore/customer/Customers.class | Bin 729 -> 2203 bytes .../me/smartstore/group/Groups.class | Bin 1031 -> 975 bytes .../me/smartstore/menu/GroupMenu.class | Bin 3398 -> 5504 bytes src/me/smartstore/SmartStoreApp.java | 7 +- src/me/smartstore/customer/Customer.java | 8 ++ src/me/smartstore/group/Group.java | 5 + src/me/smartstore/menu/GroupMenu.java | 129 +++++++++++++++++- src/me/smartstore/menu/Menu.java | 4 +- 10 files changed, 144 insertions(+), 9 deletions(-) diff --git a/out/production/KDTBE5_Java_ToyProject/me/smartstore/SmartStoreApp.class b/out/production/KDTBE5_Java_ToyProject/me/smartstore/SmartStoreApp.class index be06281717d797ca6a03ec884a2b680529f7d3fb..ead144217203f54033a5d15a6f76ee08233bfcf2 100644 GIT binary patch delta 986 zcmYL|*-uqh7{!0*p36PwY_>{H4GlE`O$y3YLpY-ny(X9#AAD;33y3B@=zrjYA;$Ra1Cjf%zrEI8`#bAfJNIzb%dF=AKej&w zO1T#hW0J>YC3T9T&@NM%X6fmQ8GL7VGZnL#ZFk=X%;5*0xr%wr_gUbx&}Wg)j~+E1 zixo?#b#V?}R(wHSz*3eeLYCXE^)7C&O5ti);Sx8m?eR*F21O%3g<@!pVlC?um3?I| zKSeg{t&4h}4bpYVNuP}_h0|*-*%aciITTl0t@~}($56z#P@%T$~j`Q~B z1&6ez`i)IR-F3L;BA0wFTjk$A|JeGkW*p_3E0jN67{3s6uX4?FCf1tw-VoF1o#>NT zUALxgWxdCBE5B`u{e0)Hsqr7hTOD#ud5~>Nf`Xz#Ni;5RAt}f%v;jm_W{;e*G%sPzwiNQ5m&# ztp7+=p~^(HUF8hyQRRPDRdsz9oc;3jF{x?hnQC2@{15*L*$cwFFfStr2R`QO6uF<- zLE#`_^Lto1Nu)?VAl+)(84M|Ub-_eCLn4^G9}Qv0t0Kc(O)qGE&PY1M@mulnjxxs; z*VbpIcxhlF=z(Yh&Gw|oLCHlhgt delta 902 zcmYL|M@$t_6o$W<_k1(&azXMm7%&lCfbswp+ta547VHJZUMMPxz4wAx!LHZdd)XN4 zTaakt))?c?n6Pl+%AH%I#&ZYDOy->XpL6cH|M_R8ExS3p@$IkH*Fb_tQCvoQR4DOd z6ouA|WtE#le%%Tus^Vy~sdn{4Zvot1zRw!1oDpKBA)^aJjvD&hzi{Y>~ zCIr@7xWTgBXi07I*!;Au$qDtNzo~V*Cx(#p*rFN0R!tGb9@{L~uIWu5j~y25)bypq zW0z((dmM_DGH=`-=7Xzzk4DX2n#@=COMIVZKL<2JIOuUmbC_leS~N#EsySxiahe@+ z&HHe!>^-45$tjZ?&Kh{y=Zwa1%Hyo&9Ov!M3qBWZ@RHAE>#u08a!oUwq~E&{8B4-+`z|Fi`XyWS&Ly@)HuvAS5=62wlh|o56zQC1#4sqGwS0 zGg{~*Oo8g!b*Ln@#2|-ZK}*N-52|WZQmQVi+@Ald3jS4lrMy~KI(#yp)#Jo7 z(&8`hTgitM>FqGmO3wh=lsu6Xz2Z*-VwQ4}4D&6mxbYQ(cqc4BGE{Cmgi8ZsD5E^! z`03B-b|m?Lf6(B3r$SOA+9^x8RFEA<$5Rx@Nh(GBsbE+BkH6ZKiL&LSF)}!$eS9sg k6IRlYgl+jK?uu8^>^AqgBSJ0{+*$Gs5?dbFHGy6C8#Hu}g8%>k diff --git a/out/production/KDTBE5_Java_ToyProject/me/smartstore/customer/Customer.class b/out/production/KDTBE5_Java_ToyProject/me/smartstore/customer/Customer.class index 15c20d4b2c51b2e58427f27ac9b71c3085dfc5f2..51d4b9b634a6afa511d1b3026824633291cfa2a9 100644 GIT binary patch delta 610 zcmZ8dOG{fp7(H|6zA|3as?oM4u?PWUqS0z=ZGE&+>!Xb^YJ4w@HYg&Em}~d`f+Dl- zs)!pGmDVB(;zk#)3WC3)(2d&`zqvvva+z=DJLj8o=G-sUe`^w#|Bg=qbYMY1;Drx1 zI#qe8$}3g6ROwc1kA+@=*LY(gq4vHCx;c1|2xz7DO3oeJ%x`Tl1REmqvtC=qU>AyD zsDZEmo01FK*OE$9IT*q)L!ES3U9W`^2hDiLP`;M^l#Q=vKd!`6OKZ7h*TH)v2~Xtn zZo%EmZX|Q=YW_o^%*3dTl!Gy(Gb`-|Nj29*Tp}2N;b%V1A>6hKE#55A2s|)1Qi=iMkp>dx+H(+Za8Bc~G1d z9y$aA!+1n!_1zR6qn0|QMtMD>X2j*SFSKq&f5O^@!S|zQu#;rYW3-Oo+oyT%y`cg+ zos+OIN_`4Jilx+_5D!F(>JhY{mDGc9@RS@iv=MKBTcs*nyId6hfSBdVWa0=V%HjW% z8M!0;?3vsX;k0>7BDnt_<~(1A#6YfhsW_f{Ivtp%T@aVSET(9(pL(160a|Zw0rdG= Ai~s-t delta 425 zcmZ8c%Su8~6kYco@4em!6_#3N5L5$S+1uWkrajcm>^TW6A`l6J2pTr(1I{?8K{E$M z8DjJpH|=*S+UL@!!Cw39wbnUnpKtG#C-L#qcm)u{jsYDbIy8(57!wc^FfN1%4U-0@ zFs)%m^jV?Ix#(u{KH-;nO}=3ZNbx<^+mp5s#G-_ja_OuTt(1ZgfV9QaN=@44UrLr~(0N9UNX-xD>NDdn zhPR@Io}k`BVb#z(v|R8JEKF60vr2n0v=h4EAWYG+X_^<&MJsd=(@i=MfDfJ2#VL#k zB+@PP6DK1|tOBMrNkk9uxas!myG(=>>o7!uY$vEBgZ^-0x}`yWY4#P&20enie~xuK f*RtKdzg&hP+ck_Lb%V45HX)pGnw>PyQzd=@uU0;u diff --git a/out/production/KDTBE5_Java_ToyProject/me/smartstore/customer/Customers.class b/out/production/KDTBE5_Java_ToyProject/me/smartstore/customer/Customers.class index 1f17c20cc8c7431be4f954941e589187f1788651..f14a047d0c7d2ac7696b023df0c3cf5785f36b1f 100644 GIT binary patch literal 2203 zcma)7T~ixX7=BK^mMjb9D;Ov(rC%l>q@^v`0zJ}i zVe*$?@lJ#ls9B?6SbB~n)4O4=JBG4RwG=F|k1J-jpxb4OC0=Yupj(!{S&ChnmGg8% zu&HfRarRAJDVD8_aoLp3Y2WMU*gbti*Kinv8jjFn~h>N8ESUL|f9ZjB6UM zV@06P4X*2ehE=?!Af@4L+|Y0nw=}#Xt#{?HjA1s=y}2oqhWBKm+jw8W2O4yw6=XEr zkxoMncaheR1@GdZo66NFfqr+iu1em?;U*o_$Js(($^3}Tqwsi@UTR1n6iGyrvW2mn zUdYC-rtcXUTPmB;1u6E`&2?@W`ZsC`;g&=D)>h?E7Uq}cug@mgu7(S*E3?KGFg`5n zIi4vLX|67Mi`AzR%RErZnR;04t{_&6ww_xx^DJ7PVOh8IykQ&G{%6>O?01GefFpZ* z(JWN?Lu|^6)+GwIku@xmbT&B!TFio-(sN~&)!kU_vcAcugeSBSd&?S{mOO@j1?4^%S1^66r73WHD)`lNL4F3Sn_wathwTBEqJJE9Vp_Siu z9F@o_9>*NEARn$1HLe-%lAoSO@coRoAK}0G7=dr$p43SU}YWX!AVBE5FI3W z8IdZL=QFwjfcVNg!JT-tw&T@2kJOpBqjM~T|knDd`;{pU65Wkd=0gw0+uQ2L?Pi!&YFl$xFHb%?m$Zr(w&q)_h;8ze6`~b)L!+*m67kBSqsdEQ& V;T_C}d+8(5DM!txG49M~{sx~|6aD}I delta 323 zcmZXPJx&8L6ofx}@hP;T^}?a#Az+FjALb5i=ris%nI~lLh8UjisZUMzEw%U#tj} zaXqKYmJqMWrP$&0pRr5IHz;3L2f6%ubmH+?% diff --git a/out/production/KDTBE5_Java_ToyProject/me/smartstore/group/Groups.class b/out/production/KDTBE5_Java_ToyProject/me/smartstore/group/Groups.class index 02b22f551fc6e754b9027b9a59569fe4cb24ef8d..2d2b245d8d7c63ba8d944f72dd3d0d1b25365c52 100644 GIT binary patch delta 446 zcmXw#y-LGy6vfZ|r)ior)~Ic5YqejtwrQb=gMv6J6a;s-Dn(kvrNzO;rJ$?C7tlf1 z3R1yAoLzhZU&BE}J&8&n=iJNTcTaK_c{P?_z8;?dtfFDTM9zeUyn%v64ThrcN(L4! z7$_U4Tr}Rp(iKR{+mg$ujR_kTqJoTfCFxk-#u8FCs;CLl{z|vuqVCmIz7*F&i-KC8>+QklZ}K_a_KZE@C-LGPAgQQ>h1&Njz(dU zZ;J|kL5R+wvwuUF3J@lyG2;Wgq*gxl^D$yUXqe976X&Es9EK7|`cW><3H4*Hwvl!3 zpVmq@!?((-nIeFRJoNhd=BH}GbF(*jjc)#5Y6 z1C4|bPm>BhQ0NBfyf{M$`v?OO40!`4F)nP@@a;i*k}7!VC=~=0$mNO{hk# z6d$3!LaUd1tMZ}}Q!=+mm1D~MikeiPpqK8TCDrbwBJO`bMAt`oOX4g5@@x`woC@@1 u)RTV0Ece;$8Arm8RsOqj9Y&C31+No(_7T#d36c0=PU0KypHoQtn)w4Y!8O7F diff --git a/out/production/KDTBE5_Java_ToyProject/me/smartstore/menu/GroupMenu.class b/out/production/KDTBE5_Java_ToyProject/me/smartstore/menu/GroupMenu.class index 5dd13d7067a870595cf7cc523042414c0417eb57..f51256089dc2808cbeeafdb324cc91b094e48b34 100644 GIT binary patch literal 5504 zcmcgw`+pSG75@&q+1V^Z5*7%M7#NUX-YZptgolL~U^NLyFqmp9Loy@-`|9p&Afkx% ziL|u7QBhG^x2+Fe5|F2&kV0*3r4Rf1t^Y*%q^93Hv)Rlh3-k)7p7o&|JzhNL#q(mp3*!An(R)esUY4;}ta(MKc-7BgE_C5_Kit^k z#hX5Cz<$xZCF5-$>V>KUGJY!KXA<(YP-ta5nv5kR+|V4>1BtK}Hxp(wt_Qlsc)*@r zBtfBQW0F&0Jx=M_qoh02Q-O>O*W_C|TJ%U#!i-T1!W^}=i+Ku<@7B#=Bw=ciPF;dp zQTa^^+>OyLN)|R75xq4T-l)gdX&XZvnb2lxom*P8So+!uD*XHV1+hDbr0#+PV9x3G{fYm8|QsMhtxbUNd2-mLX% zfshvI4z!tZBhsCLLr6%NIm)}SDkMr(kCM{2b?PzGh(-dzNGxeKMY@`XN2q^}W7A+L zq<3qfW%2GLkv5%TNI^w7Gf zsfE^PeG>94ZzPnCGT-6kA{p;6QoV-0HKU%YlCdt$)Ey&}oIXWNy<3lSX-dKrLm<#H z#+oUN&ItCw^b!e^o$@25`r4w&c&EO?5X321DL60qSSM5{xEm3R{#4!c^IIiFXS|wCwuec5`Np&hvjf5JDQ>ETj zr#5XfOjYEYDzL0$F&V+=TD)aN2u6CfkkQ2_17D}E3F%rw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_wZan`SK>*HHl!7vl1oJ+gRB|z?T?(mNsSvM>}ic>@T~dK*AY0SaT;fg z@+ZR2;dzZYyrA(Sx=hYL=+}6OzBB%T+_mV^cp0x~oW-jeuc6CAWKXeJo++0`$*Fv# zczC8Z0Au5v#_M>)#+#zwGCiu^d>#xs0{yneJ9yWuRYO+H{AS0z7UH7KS@o;WKV6zI z$3ihPXU{2~r^=I4W_NJT`ySpm%fSm)i#hLX^t2r`Yl2x@;RC7vk@+mtW?e8phrafG zVj*FE4<*b+oy=_ElvD5`Dzo6&qcR3+N2W&YN08Im#;EPa3MZ0R(N@EFU@ZbzhY0Gh zgEud%2v^PNRzvgQ)@})n!bcgS3?szED9<}-(TtK3yQ&}-u362a?HnOJ)Sc#waHtMFsMS}UZ)NqkpSov=wNxl`3 zpC5a<>KoZ)FZZ#J{QAj1Piukye5l%FnsmDPdiFBT%Z!0)kNmvM?`4iWfnoHmz7JVh rEyMoCPK7>&{y#VsFLS`Sn{b}mVWS`7W6Tq^$a@Vv)3iNQl{5bWWoE}n diff --git a/src/me/smartstore/SmartStoreApp.java b/src/me/smartstore/SmartStoreApp.java index dc4f8817..1754c712 100644 --- a/src/me/smartstore/SmartStoreApp.java +++ b/src/me/smartstore/SmartStoreApp.java @@ -50,11 +50,14 @@ public SmartStoreApp test() { ((int) (Math.random() * 5) + 1) * 100000)); } + allCustomers.add(new Customer("test1","test1",9,90000)); + allCustomers.add(new Customer("test2","test2",9,3100000)); + allCustomers.refresh(allGroups); + System.out.println("allCustomers = " + allCustomers); System.out.println("allGroups = " + allGroups); - // @TODO: refresh do not implemented yet. - allCustomers.refresh(allGroups); + return this; // smartStoreApp } diff --git a/src/me/smartstore/customer/Customer.java b/src/me/smartstore/customer/Customer.java index 1d1415e8..1cdadedd 100644 --- a/src/me/smartstore/customer/Customer.java +++ b/src/me/smartstore/customer/Customer.java @@ -64,6 +64,14 @@ public void setCustomerTotalPay(int customerTotalPay) { this.customerTotalPay = customerTotalPay; } + public Group getGroup() { + return group; + } + + public void setGroup(Group group) { + this.group = group; + } + @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/src/me/smartstore/group/Group.java b/src/me/smartstore/group/Group.java index e80f33b3..52cf3689 100644 --- a/src/me/smartstore/group/Group.java +++ b/src/me/smartstore/group/Group.java @@ -9,6 +9,11 @@ public class Group { public Group() { } + public Group(GroupType groupType){ + this.groupType = groupType; + + } + public Group(Parameter parameter, GroupType groupType) { this.parameter = parameter; this.groupType = groupType; diff --git a/src/me/smartstore/menu/GroupMenu.java b/src/me/smartstore/menu/GroupMenu.java index 37cb17e3..a40df2d7 100644 --- a/src/me/smartstore/menu/GroupMenu.java +++ b/src/me/smartstore/menu/GroupMenu.java @@ -2,6 +2,7 @@ import me.smartstore.customer.Customers; import me.smartstore.exception.InputEndException; +import me.smartstore.exception.InputRangeException; import me.smartstore.group.Group; import me.smartstore.group.GroupType; import me.smartstore.group.Groups; @@ -34,8 +35,8 @@ public void manage() { "Back"}); if (choice == 1) setParameter(); - else if (choice == 2) {}// viewParameter(); - else if (choice == 3) {}// updateParameter(); + else if (choice == 2) viewParameter(); + else if (choice == 3) updateParameter(); else break; // choice == 4 } @@ -44,7 +45,7 @@ public void manage() { public GroupType chooseGroup() { while ( true ) { try { - System.out.print("Which group (GENERAL (G), VIP (V), VVIP (VV))? "); + System.out.println("Which group (GENERAL (G), VIP (V), VVIP (VV))? "); String choice = nextLine(Message.END_MSG); // group (str) -> GroupType (enum) // "VIP" -> GroupType.VIP @@ -61,20 +62,138 @@ public GroupType chooseGroup() { } public void setParameter() { // 초기화할 때만 호출 가능 + //todo : end 누르면 이전 페이지로 안넘어가고 chooseGroup에서 리턴된는 null로 새로운 그룹을 만듬 while ( true ) { GroupType groupType = chooseGroup(); + if (groupType == null){ //chooseGroup에서 end입력되면 null리턴함 + allCustomers.refresh(allGroups); // 파라미터가 변경되었거나 추가되는 경우, 고객 분류를 다시 해야함 + break; + } // GroupType에 해당하는 group 객체를 찾아야 함 Group group = allGroups.find(groupType); + if (group != null && group.getParameter() != null) { // group.getParameter()이 null이 아니면 이미 초기화됨 System.out.println("\n" + group.getGroupType() + " group already exists."); System.out.println("\n" + group); - } else { + } + else{ Parameter parameter = new Parameter(); + int minimumSpentTime = 0; + int minimumTotalPay = 0; // time, pay 사용자 입력받은 후, 설정 필요 + while( true ){ + + + int choice = chooseMenu(new String[]{ + "Minimum Spent Time", + "Minimum Total Pay", + "Back"}); + if (choice == 1) { + parameter.setMinTime(inputMinimumSpentTime()); + } + else if (choice == 2) { + parameter.setMinPay(inputMinimumTotalPay()); + } + else{ + allGroups.add(new Group(parameter, groupType)); + group = allGroups.find(groupType); + System.out.println("\nGroupType: " + group.getGroupType()); + System.out.println("Parameter: " + group.getParameter()); + break; + } + + } + +// group.setParameter(parameter); // 그룹이 없어서 set하는건데 구조상 필요없는거 아닌가? + + } + } + } - group.setParameter(parameter); + public void viewParameter() { + while ( true ){ + GroupType groupType = chooseGroup(); + if (groupType == null){ //chooseGroup에서 end입력되면 null리턴함 allCustomers.refresh(allGroups); // 파라미터가 변경되었거나 추가되는 경우, 고객 분류를 다시 해야함 + break; + } + + Group group = allGroups.find(groupType); + System.out.println("GroupType: " + group.getGroupType()); + System.out.println("Parameter: " + group.getParameter()); + } + } + + public void updateParameter(){ + // todo : 파라미터가 하나도 없는 경우 설정하라는 문구가 떠야함 + while( true ) { + GroupType groupType = chooseGroup(); + if (groupType == null){ //chooseGroup에서 end입력되면 null리턴함 + allCustomers.refresh(allGroups); // 파라미터가 변경되었거나 추가되는 경우, 고객 분류를 다시 해야함 + break; + } + + Group group = allGroups.find(groupType); + System.out.println("\nGroupType: " + group.getGroupType()); + System.out.println("Parameter: " + group.getParameter()); + + while ( true ){ + int choice = chooseMenu(new String[]{ + "Minimum Spent Time", + "Minimum Total Pay", + "Back"}); + + if (choice == 1) { + Integer minimumSpentTime = inputMinimumSpentTime(); + if (minimumSpentTime == null) continue; + else group.getParameter().setMinTime(minimumSpentTime); + } + else if (choice == 2) { + Integer minimumTotalPay = inputMinimumTotalPay(); + if (minimumTotalPay == null) continue; + else group.getParameter().setMinTime(minimumTotalPay); + } + else{ + System.out.println("\nGroupType: " + group.getGroupType()); + System.out.println("Parameter: " + group.getParameter()); + break; + } + } + + + } + } + + public Integer inputMinimumSpentTime(){ + while (true){ + try{ + System.out.println("\nInput Minimum Spent Time: "); + int minimumSpentTime = Integer.parseInt(nextLine(Message.END_MSG)); + if(minimumSpentTime>0) return minimumSpentTime; + throw new InputRangeException(); + } catch (InputEndException e){ + System.out.println(Message.ERR_MSG_INPUT_END); + return null; + } catch (IllegalArgumentException e) { + System.out.println(Message.ERR_MSG_INVALID_INPUT_RANGE); + } + } + + } + + public Integer inputMinimumTotalPay(){ + while (true){ + try { + System.out.println("\nInput Minimum Total Pay: "); + int minimumTotalPay = Integer.parseInt(nextLine(Message.END_MSG)); + if(minimumTotalPay>0) return minimumTotalPay; + throw new InputRangeException(); + } catch (InputEndException e){ + System.out.println(Message.ERR_MSG_INPUT_END); + return null; + } catch (IllegalArgumentException e) { + System.out.println(Message.ERR_MSG_INVALID_INPUT_RANGE); } } } diff --git a/src/me/smartstore/menu/Menu.java b/src/me/smartstore/menu/Menu.java index 4a318760..f15ef077 100644 --- a/src/me/smartstore/menu/Menu.java +++ b/src/me/smartstore/menu/Menu.java @@ -17,14 +17,14 @@ default String nextLine(){ default String nextLine(String end){ System.out.println("** Press 'end', if you want to exit! **"); String str = scanner.nextLine().toUpperCase(); - if (str.equals(end)) throw new InputEndException(); + if (str.equals(end) || str.equals("END")) throw new InputEndException(); return str; } default int chooseMenu(String[] menus) { while ( true ) { // 예외 복구 while try { - System.out.println("==============================="); + System.out.println("\n==============================="); for (int i = 0; i < menus.length; i++) { System.out.printf(" %d. %s\n", i + 1, menus[i]); } From 5bd328743615aea957581e3505134c7c0e1ae735 Mon Sep 17 00:00:00 2001 From: ho30archive Date: Tue, 9 May 2023 20:58:25 +0900 Subject: [PATCH 05/11] fix : fix chooseMenu MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit InputRangeException 예외 추가 --- .../me/smartstore/menu/Menu.class | Bin 2123 -> 2354 bytes src/me/smartstore/menu/Menu.java | 3 ++- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/out/production/KDTBE5_Java_ToyProject/me/smartstore/menu/Menu.class b/out/production/KDTBE5_Java_ToyProject/me/smartstore/menu/Menu.class index 5177169580a6a3d6779f8e6c2ccef3b000f3cbfa..68fc1c27e9bb8254325cf0f192225da922fa3853 100644 GIT binary patch delta 1003 zcmZva%}-QU7{-6+&cL~I=SuY|Qe-ICiYPELRzzErf>o>^h+6y_KN(=;!(j#yQH&`` zBQDyNy-AaH(ZqJ)ri&Jm(Uz!tyJ+IpjsJi#aoLd4_uMhAT-@_M?|Gl|ocliS`FrKO zH~Z|rzn%a)xf#P}k3%hAIHcGcV;|i%`yIaIfY~`{b4YX8Ax4kQ5u0AkQHNt3H8|8RZJ zSY|qt%4PDysov}31KG*_g~{>ERPaVMsrI1OYO7q&$1WSFcNwH!Gvt!xaxiQqR}H(2 zFzPbK6-A`GcVFW7V&7_l^__*RuZ6e740ME^*9ky!d6&eP=YQjTCGJ)+@ivs&;Pnq??P-Y-eKl@~FoB;^8+ z8o^1qqD5FStR*&RQd&w|`K0s*>N|9Jd~TlEs249%9_dIlKlz1?^F%$j>@h3Skwmor z5fy#uXmes)Uy%<^-?7w#iahG0DT(VBtv*`LC@olQ4 delta 893 zcmYjQOHUI~7(I7p%1ozYfj)xB02O(+f}$v*Ac~*@6%`TclUEf~S`&?d#H1Tnnwa1u z8W%3q1sfMyk^&MTZuKYl7yJc=i04j~m`T3x+%w-j-)klt_+FIx_WScXfWt_8VdI#I zQgoPzqSK4x=rVA^#7T5Z=9G>e69#$>oHlSq$5|77=$G#Y48)~B=c5L%_hC@Sc@shO z>bRieqJbd;mvjtE)yp!;h>lSKec{js)S(rqdK&4ZxmN*f$zIw_+61Obe z#pWM#I&ZX)aSyXnAhoorEs2Z`i(?V2l;se4h*=Zu zZk`U(3wkpPk%N+h`jICERkQ`}8$b3CTlpwdqlPD`P)jQn9y3~{ug*dXcycJ%R*J`> zIb`(L@U6i}EW^7Ilj5o?9)Lz1;2MIoA#!0iQ6w++HxXq~hkB+8@M$1Y(8zlR#3rhA zE>j?ez4=naFm(6!ye!3JDQbtEiLSpxjU;@YFR&7-t&Oc<$529x+ATvl_(z^7VsY!o zzbn!g=1|nQieiBk1UhW(Eqr!#{XIPPhcyJ*NoXT3<4TxfaqFdvce?ng+tn!d8b*S4 z9A#maJBnGhDGBNG1L#Dd(`YnjqU7q4Vsnq!j+}KTCvTE#LNnVPpwvDWO|b3#Xd#z! z(E%c0etT5&+-56BAqP}NjZJvPFVt Date: Wed, 10 May 2023 09:48:24 +0900 Subject: [PATCH 06/11] fix : fix nextLine(String end) --- .../me/smartstore/menu/Menu.class | Bin 2354 -> 2351 bytes src/me/smartstore/menu/Menu.java | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/out/production/KDTBE5_Java_ToyProject/me/smartstore/menu/Menu.class b/out/production/KDTBE5_Java_ToyProject/me/smartstore/menu/Menu.class index 68fc1c27e9bb8254325cf0f192225da922fa3853..4d215b81abedd8d01c871a80ca37152d2633de4f 100644 GIT binary patch delta 97 zcmdlav|eb#88-1|1||k(1_lPLO$;nTtlJpaHZd@6V_=&6jLp!3pFxB{gF%!*9Vo8= qQ3d2{0(n674B8Aj42%r?4AKm`Ko%2&9#E8%f$0x}!e)Q=$BY0SfDRh~ delta 100 zcmZ24v`J{g88)dl1||k(1_lP*O$;nTtlJpaHZd@6V_@3Gz&!aeo1ujeg9w8*gD8VK tP>BLWA%g~kCXffz0+i8VU}O+tkOs1KfClLSML8Lm{xB$S_F;d_2molC4(R{@ diff --git a/src/me/smartstore/menu/Menu.java b/src/me/smartstore/menu/Menu.java index bacd154e..8c88b1b7 100644 --- a/src/me/smartstore/menu/Menu.java +++ b/src/me/smartstore/menu/Menu.java @@ -16,7 +16,7 @@ default String nextLine(){ default String nextLine(String end){ System.out.println("** Press 'end', if you want to exit! **"); - String str = scanner.nextLine().toUpperCase(); + String str = scanner.nextLine(); if (str.equals(end) || str.equals("END")) throw new InputEndException(); return str; } From d743feb5f6b66c5db5b02026cf63716c418f3511 Mon Sep 17 00:00:00 2001 From: ho30archive Date: Wed, 10 May 2023 13:38:49 +0900 Subject: [PATCH 07/11] feat : set CustomerMenu MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 기초적인 부분들 완성 AddCustomer은 내용이 길어져 클래스를 나누었음 Todo들 수정해야함 --- .../me/smartstore/customer/Customer.class | Bin 3069 -> 3080 bytes .../me/smartstore/group/Group.class | Bin 2192 -> 2276 bytes .../me/smartstore/menu/CustomerMenu.class | Bin 785 -> 0 bytes .../me/smartstore/menu/GroupMenu.class | Bin 5504 -> 5519 bytes .../me/smartstore/menu/MainMenu.class | Bin 1510 -> 1537 bytes .../me/smartstore/menu/Menu.class | Bin 2351 -> 2522 bytes src/me/smartstore/customer/Customer.java | 2 +- src/me/smartstore/menu/CustomerMenu.java | 29 ---- src/me/smartstore/menu/GroupMenu.java | 4 +- src/me/smartstore/menu/MainMenu.java | 2 +- src/me/smartstore/menu/Menu.java | 7 + .../smartstore/menu/customer/AddCustomer.java | 157 ++++++++++++++++++ .../menu/customer/CustomerMenu.java | 104 ++++++++++++ 13 files changed, 273 insertions(+), 32 deletions(-) delete mode 100644 out/production/KDTBE5_Java_ToyProject/me/smartstore/menu/CustomerMenu.class delete mode 100644 src/me/smartstore/menu/CustomerMenu.java create mode 100644 src/me/smartstore/menu/customer/AddCustomer.java create mode 100644 src/me/smartstore/menu/customer/CustomerMenu.java diff --git a/out/production/KDTBE5_Java_ToyProject/me/smartstore/customer/Customer.class b/out/production/KDTBE5_Java_ToyProject/me/smartstore/customer/Customer.class index 51d4b9b634a6afa511d1b3026824633291cfa2a9..3b81409c37552b8dce4f49b785be0450b2755bd6 100644 GIT binary patch delta 30 lcmew>-XXEUm4z{VvKvbjw|h~3X+cP3L8_I)<^?RV>;R#N3LF3c delta 18 ZcmeB>_$$7_m4z{8vKvd(=G82*>;OID1_%HE diff --git a/out/production/KDTBE5_Java_ToyProject/me/smartstore/group/Group.class b/out/production/KDTBE5_Java_ToyProject/me/smartstore/group/Group.class index b478ef88acb82e77c0508dc4b4cabf186e51e381..cf2374a5d7e0e948037924992a20f829a988c01d 100644 GIT binary patch delta 362 zcmY*Vy-ve05dLh(jvJD;Ng7fp5vphm%^tVeM%q-=y&9QlDHM zLvjIL{sNH~&yX`l5+V0G6n7sE0@Tnz#Av-zBSwo6`eVM-QKx2zSH>EpcRfo@A(-Ye( zO@@RnShK^L9&1hy)Nl^9fVn}G&mkGf2e{4@j(X(DYPDYVie0!Epp6_E3c7XAGc_7J erE9c+E!EX$7+wz8qoysiDrq{hiP)zzd-w~&9yK}u delta 310 zcmZvXu}%U(5QhJqz1=sQ(4&5Wu|FU^n( zHmp;#{R%w=KnO)6c%p%54jF7pZ1KPz>LN6Q4y z)^r6`z7oFjFTabJpKW6Hgs<_1J2|5E3^a$mLDZZC|WrKc#;M1& diff --git a/out/production/KDTBE5_Java_ToyProject/me/smartstore/menu/CustomerMenu.class b/out/production/KDTBE5_Java_ToyProject/me/smartstore/menu/CustomerMenu.class deleted file mode 100644 index fdb3b8890c25b20fda84448fa3bdf165cbe00e83..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 785 zcma)4O>fgc5Pcgvw&OTWYDxh~97KtDG>b#EaB$U(=nH#%sdcNagNdN)07Un=$-5EcyuB{$*}epZ;J!5 z!{ao~#R9B$j|P9*+wC2oO(*JroY8BmY3VX(sG)^rVq8LZNTHsUw_sn;_=rky2JIaf z;n&1haDl!{lm)6_pia3BtPs+`S`??G741tXVBl!&mz~DlP#06&r4K&yA1KlUxD_6|DaRx6h~S diff --git a/out/production/KDTBE5_Java_ToyProject/me/smartstore/menu/GroupMenu.class b/out/production/KDTBE5_Java_ToyProject/me/smartstore/menu/GroupMenu.class index f51256089dc2808cbeeafdb324cc91b094e48b34..2a0bc5c9ebc6478dbe6f1cabcbef1ef6cd805421 100644 GIT binary patch delta 261 zcmW;G&q@Me6o&EVOB7wnj6)$o6O;%|WNvI#D|dy|CZhH&x`+t+2NemOuE2t6qv z8_m*m6?6+N+jaxfK@ObN?|siX@v2_4W2FM(IxrSvO`AZz(|L)klBr0^o-+mcvD|V< zaw#Oy#`Q_~(Xk(`w=@!?tox9x?lUbpC&dL0m&|a*Jl7PsVS_5W+)Ldqrn}VW^T+_7 z5l`}KyY3O2Y-v}V9^33-H2J_j2TV=g%4b%MCwrOGT%9BhY@V5=$pS4F30UTZ6+*rB i${OuE=PTD!_@=P0@Ll1D!hyn}!cT=Gg=6`1ZvO#f7eI0V delta 260 zcmW;GKTAS!6vpxI?}pK(LGJZtL7+lPgORn|prNIPpaxqUatMXqM^FY9*l?D1!Qav! zt%M6!mi^g+-a_x9rrSXdJj?k!hjURpDt05!ZIjS}M=@U7SouyaO6-MZQ$jyu^77+l z)-97ZZrXUer*MKT%{p_M$67tXr9r?cvoy(ZMu~GaXi-5V@>i$(w2A02z{;cgRjDq%4d~Bl`kq^RgP4?seD)Yq4HDAOzR&-T|LSG diff --git a/out/production/KDTBE5_Java_ToyProject/me/smartstore/menu/MainMenu.class b/out/production/KDTBE5_Java_ToyProject/me/smartstore/menu/MainMenu.class index 048ad111cbff1eddb1add885b1a9427f62ef8a95..bb71cdd50133222b5dea391678767a8773b81239 100644 GIT binary patch delta 73 zcmaFH-N-Yckx^^nLlKVT(&Cc*+|;6tQ=OR@H6|-E3roO+^qrw{zNvYoj0`%H9hk-7 L>Ng88UtEOHt+02_=(2^lO9ibX1>~;YKpW)%r!fl1`~5ywiP|5DS13+#$xZk zvTNp@8a?al%Dh;6>%=WR$GpcBm9-Cnb;}Bxm%-u2*Vs7nI)_&YM7C53u3}ZOt2pL+ zu(iJyO&t+gu$7%05Mt~vofZztO@z`(UYD(Qd}n#?n6N#Mw@>$m6uLpOX^RE4++^jB|*bbn;?9Nrx45Qo2h59xkyo=65J9srpEQI<(q1i{f^6$Kdulzmf%O%TSN?LuNgV&cJ= z_Al@cz=JmrUQ9fAGJ%tKuX^%otT%^FeO*<*`c?POl8@1Y@Bco30ovL1h|}X!L9b6E zeID28H{9^K$v~JHG~Ch*`FLauw+(kR!#*R7hAnpu_Y7kpjz?sY3>jfUGwBl}qnXl7 z8)gi%nmNO~W+8O&?uU*KG>h+E|4~`{R-LGnU3R)6OPtp%2duDakDO#=E#M*R0UJEB zznoURNm>#2ZNfcgJKaRlRzQx&0Z(|UsLZF|xY5Y7Q1hG@iU#}Jsj$UPkv(?*nwM+` zY_jv|N5NO6PTBW`!*)mao{nND;S8nJ60_fQhucK6Rp#WNOe*CR%eqO4EmV>U-${ZD zRZLUOA~j^WAS))>5`B(3wuSeoXP*XM315`Y9zf$uy@g9SqK?s;r>r=%aanS?Jhcn$ x=cxlHD#Ak%)kzHL3Msql#mldvG-ro2F*#)gifg2$!O%(Ce(;)gm)sn>{{!lwPJaLZ diff --git a/src/me/smartstore/customer/Customer.java b/src/me/smartstore/customer/Customer.java index 1cdadedd..e34b3ba1 100644 --- a/src/me/smartstore/customer/Customer.java +++ b/src/me/smartstore/customer/Customer.java @@ -92,7 +92,7 @@ public String toString() { ", customerId='" + customerId + '\'' + ", customerTotalTime=" + customerTotalTime + ", customerTotalPay=" + customerTotalPay + - ", group=" + group + + ", group=GroupType: " + group + '}'; } } diff --git a/src/me/smartstore/menu/CustomerMenu.java b/src/me/smartstore/menu/CustomerMenu.java deleted file mode 100644 index a520c007..00000000 --- a/src/me/smartstore/menu/CustomerMenu.java +++ /dev/null @@ -1,29 +0,0 @@ -package me.smartstore.menu; - -import me.smartstore.group.Groups; - -public class CustomerMenu implements Menu{ - // singleton - private static CustomerMenu customerMenu; - - public static CustomerMenu getInstance() { - if (customerMenu == null) { - customerMenu = new CustomerMenu(); - } - return customerMenu; - } - - private CustomerMenu() {} - - @Override - public void manage() { - while ( true ) { // 서브 메뉴 페이지를 유지하기 위한 while - int choice = chooseMenu(new String[]{ - "Add Customer", - "View Customer", - "Update Customer", - "Delete Customer", - "Back"}); - } - } -} diff --git a/src/me/smartstore/menu/GroupMenu.java b/src/me/smartstore/menu/GroupMenu.java index a40df2d7..612f0b2f 100644 --- a/src/me/smartstore/menu/GroupMenu.java +++ b/src/me/smartstore/menu/GroupMenu.java @@ -126,7 +126,8 @@ public void viewParameter() { } public void updateParameter(){ - // todo : 파라미터가 하나도 없는 경우 설정하라는 문구가 떠야함 + // todo : 파라미터가 하나도 없는 경우 설정하라는 문구가 떠야함, Try-catch로 end예외 잡아야할듯? + // todo : 파라미터값 업데이트 되면 고객재분류 해야됨 while( true ) { GroupType groupType = chooseGroup(); if (groupType == null){ //chooseGroup에서 end입력되면 null리턴함 @@ -157,6 +158,7 @@ else if (choice == 2) { else{ System.out.println("\nGroupType: " + group.getGroupType()); System.out.println("Parameter: " + group.getParameter()); + allCustomers.refresh(allGroups); break; } } diff --git a/src/me/smartstore/menu/MainMenu.java b/src/me/smartstore/menu/MainMenu.java index a166608d..d116c583 100644 --- a/src/me/smartstore/menu/MainMenu.java +++ b/src/me/smartstore/menu/MainMenu.java @@ -1,6 +1,6 @@ package me.smartstore.menu; -import me.smartstore.group.Groups; +import me.smartstore.menu.customer.CustomerMenu; public class MainMenu implements Menu{ private final CustomerMenu customerMenu = CustomerMenu.getInstance(); diff --git a/src/me/smartstore/menu/Menu.java b/src/me/smartstore/menu/Menu.java index 8c88b1b7..f35873e9 100644 --- a/src/me/smartstore/menu/Menu.java +++ b/src/me/smartstore/menu/Menu.java @@ -14,7 +14,14 @@ default String nextLine(){ return scanner.nextLine().toUpperCase(); } + // TODO: 2023/05/10 nextLine이 쫌 꼬였음 UpperCase가 되어야되는곳과 아닌곳이 구별되어야 함 ㅠㅠ default String nextLine(String end){ + System.out.println("** Press 'end', if you want to exit! **"); + String str = scanner.nextLine().toUpperCase(); + if (str.equals(end) || str.equals("END")) throw new InputEndException(); + return str; + } + default String nextLineNotUpperCase(String end){ System.out.println("** Press 'end', if you want to exit! **"); String str = scanner.nextLine(); if (str.equals(end) || str.equals("END")) throw new InputEndException(); diff --git a/src/me/smartstore/menu/customer/AddCustomer.java b/src/me/smartstore/menu/customer/AddCustomer.java new file mode 100644 index 00000000..db3b8669 --- /dev/null +++ b/src/me/smartstore/menu/customer/AddCustomer.java @@ -0,0 +1,157 @@ +package me.smartstore.menu.customer; + +import me.smartstore.customer.Customer; +import me.smartstore.customer.Customers; +import me.smartstore.exception.InputEndException; +import me.smartstore.group.Groups; +import me.smartstore.menu.Menu; +import me.smartstore.util.Message; + +import java.awt.*; + +public class AddCustomer implements Menu { + private final Customers allCustomers = Customers.getInstance(); + private final Groups allGroups = Groups.getInstance(); + + //singleton + private static AddCustomer addCustomer; + + public static AddCustomer getInstance(){ + if (addCustomer == null){ + addCustomer = new AddCustomer(); + } + return addCustomer; + } + + private AddCustomer(){} + + //----- + + public void addCustomer(){ //Todo : update에서도 활용가능하게 함수화 하기, 이 함수 클래스화 가능한지 생각해보기 + while(true){ + try { + System.out.println("How many customer to input?"); + int n = Integer.parseInt(nextLine(Message.END_MSG)); + + for (int i = 0; i < n; i++) { + System.out.println("====== Customer "+ (i+1) + " Info. ======"); + allCustomers.add(inputCustomerInfo(null)); + // 고객정보 입력받는 함수 추가됨 + } + allCustomers.refresh(allGroups); + break; + }catch (InputEndException e){ + System.out.println(Message.ERR_MSG_INPUT_END); + break; + }catch (IllegalArgumentException e){ + System.out.println(Message.ERR_MSG_INVALID_INPUT_RANGE); + } + } + } + + public Customer inputCustomerInfo(Customer customer){ + //cusotmer이 null일 때 -> 새로운 고객객체를 생성할 때 + //cusotmer이 null이 아닐때 -> 기존 고객정보를 수정할 때 + String name = ""; + String id = ""; + Integer spentTime = 0; + Integer totalPay = 0; + if (customer != null){ + name = customer.getCustomerName(); + id = customer.getCustomerId(); + spentTime = customer.getCustomerTotalTime(); + totalPay = customer.getCustomerTotalPay(); + } + while (true){ + int choice = chooseMenu(new String[]{ + "Customer Name", + "Customer ID", + "Customer Spent Time", + "Customer Total Pay", + "Back"}); + + if (choice == 1) { + name = inputCustomerName(); + if(name == null) continue; + } else if (choice == 2) { + id = inputCustomerID(); + if(id == null) continue; + } else if (choice == 3) { + try{ + spentTime = inputSpentTime(); + }catch (NullPointerException e){ + continue; + } + + } else if (choice == 4) { + try{ + totalPay = inputTotalPay(); + }catch (NullPointerException e){ + continue; + } + } else { + return new Customer(name, id, spentTime, totalPay); + } + + } + + } + + public String inputCustomerName(){ + try { + System.out.println("\nInput Customer's Name: "); + String name = nextLineNotUpperCase(Message.END_MSG); + + return name; + } catch (InputEndException e){ + System.out.println(Message.ERR_MSG_INPUT_END); + return null; + } + + } + + public String inputCustomerID(){ + try{ + System.out.println("\nInput Customer's ID: "); + String id = nextLineNotUpperCase(Message.END_MSG); + return id; + } catch (InputEndException e){ + System.out.println(Message.ERR_MSG_INPUT_END); + return null; + } + } + + public Integer inputSpentTime(){ + try{ + System.out.println("\nInput Customer's Spent Time: "); + Integer spentTime = Integer.parseInt(nextLine(Message.END_MSG)); + return spentTime; + } catch (InputEndException e){ + System.out.println(Message.ERR_MSG_INPUT_END); + return null; + } catch (IllegalArgumentException e){ + System.out.println(Message.ERR_MSG_INVALID_INPUT_FORMAT); + return null; + } + } + + public Integer inputTotalPay(){ + try{ + System.out.println("\nInput Customer's Total Payment: "); + Integer totalPay = Integer.parseInt(nextLine(Message.END_MSG)); + return totalPay; + } catch (InputEndException e){ + System.out.println(Message.ERR_MSG_INPUT_END); + return null; + } catch (IllegalArgumentException e){ + System.out.println(Message.ERR_MSG_INVALID_INPUT_FORMAT); + return null; + } + } + + + @Override + public void manage() { + + } +} diff --git a/src/me/smartstore/menu/customer/CustomerMenu.java b/src/me/smartstore/menu/customer/CustomerMenu.java new file mode 100644 index 00000000..082eeba1 --- /dev/null +++ b/src/me/smartstore/menu/customer/CustomerMenu.java @@ -0,0 +1,104 @@ +package me.smartstore.menu.customer; + +import me.smartstore.customer.Customer; +import me.smartstore.customer.Customers; +import me.smartstore.exception.InputEndException; +import me.smartstore.group.Groups; +import me.smartstore.menu.Menu; +import me.smartstore.util.Message; + +import java.util.InputMismatchException; +import java.util.Scanner; + +public class CustomerMenu implements Menu { + private final Customers allCustomers = Customers.getInstance(); + private final AddCustomer addCustomer = AddCustomer.getInstance(); + private final Groups allGroups = Groups.getInstance(); + Scanner scanner = new Scanner(System.in); + + // singleton + private static CustomerMenu customerMenu; + + public static CustomerMenu getInstance() { + if (customerMenu == null) { + customerMenu = new CustomerMenu(); + } + return customerMenu; + } + + private CustomerMenu() {} + + @Override + public void manage() { + while ( true ) { // 서브 메뉴 페이지를 유지하기 위한 while + int choice = chooseMenu(new String[]{ + "Add Customer", + "View Customer", + "Update Customer", + "Delete Customer", + "Back"}); + if (choice == 1) addCustomer.addCustomer(); + else if (choice == 2) viewCustomer(); + else if (choice == 3) updateCustomer(); + else if (choice == 4) deleteCustomer(); + else break; + } + } + + + public void viewCustomer(){ + System.out.println("======= Customer Info. ======="); + for (int i = 0; i < allCustomers.size(); i++) { + + System.out.printf("No. %d => Customer{userId='%s', name='%s', spentTime=%d, totalPay=%d, " + , i+1,allCustomers.get(i).getCustomerId(),allCustomers.get(i).getCustomerName(),allCustomers.get(i).getCustomerTotalTime(),allCustomers.get(i).getCustomerTotalPay()); + if (allCustomers.get(i).getGroup() == null){ + System.out.println("group=GroupType: null"); + } + else { + System.out.println("group=GroupType: " + allCustomers.get(i).getGroup().getGroupType()); + } + } + } + + public void updateCustomer(){ + // 고객객체를 업데이트 할 때 기존 정보를 불려와야함. + viewCustomer(); + while (true){ + System.out.printf("\nWhich customer (1 ~ %d) ?", allCustomers.size()); + try { + int num = scanner.nextInt(); + scanner.nextLine(); + if (num > allCustomers.size()) throw new InputMismatchException(); + allCustomers.set(num-1, addCustomer.inputCustomerInfo(allCustomers.get(num-1))); + allCustomers.refresh(allGroups); + break; + }catch (InputMismatchException e) { + System.out.println(Message.ERR_MSG_INVALID_INPUT_FORMAT); + scanner.nextLine(); + } + } + + + } + + public void deleteCustomer(){ + viewCustomer(); + while (true){ + System.out.printf("\nWhich customer (1 ~ %d)? ", allCustomers.size()); + try { + int num = scanner.nextInt(); + scanner.nextLine(); + if (num > allCustomers.size()) throw new InputMismatchException(); + allCustomers.pop(num-1); + break; + }catch (InputMismatchException e) { + System.out.println(Message.ERR_MSG_INVALID_INPUT_FORMAT); + scanner.nextLine(); + } + } + + + + } +} \ No newline at end of file From b9b7232c600136ec5dd19ea4979c4490fccdda0a Mon Sep 17 00:00:00 2001 From: ho30archive Date: Thu, 11 May 2023 20:29:48 +0900 Subject: [PATCH 08/11] feat : set SummaryMenu MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 깔끔한지는 모르겠는데 구현은 완료 --- .../me/smartstore/SmartStoreApp.class | Bin 3292 -> 3339 bytes .../me/smartstore/customer/Customers.class | Bin 2203 -> 2517 bytes .../me/smartstore/menu/GroupMenu.class | Bin 5519 -> 5552 bytes src/me/smartstore/SmartStoreApp.java | 1 + src/me/smartstore/customer/Customer.java | 2 +- src/me/smartstore/customer/Customers.java | 19 ++- src/me/smartstore/menu/GroupMenu.java | 4 +- src/me/smartstore/menu/SummaryMenu.java | 155 ++++++++++++++++++ .../smartstore/menu/customer/AddCustomer.java | 6 +- 9 files changed, 180 insertions(+), 7 deletions(-) diff --git a/out/production/KDTBE5_Java_ToyProject/me/smartstore/SmartStoreApp.class b/out/production/KDTBE5_Java_ToyProject/me/smartstore/SmartStoreApp.class index ead144217203f54033a5d15a6f76ee08233bfcf2..333755b278ebec691674de92f548b7a464cc1de9 100644 GIT binary patch delta 1265 zcmZvc+jA6E5XOIJXLo1jFi`8T1hXqy&@?p#A}rW%=l{RaRLl_L)tH56nY%f8F2o^y%-^oUS~O zD*o{A*jGRU!!8l7wz)=&zgDx@m=0E(bf;zw*O};g&05x(XuZn~+~{zV=4QGa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Iqo!-t!dlQJ*akLPM1x;V`Cf;d$9>%I z%RpN^@{HMCN!iQKqn3xv6j_(8(sko*mvM`h!C?ayd=!uPGSy>d`p3<0;L>v^qR(lA>k>D;=IO$#%^pT&(UuWRjKKe4@!& zsqDk1#gSmtO{*`0N%x!RQAK@_kJkp-cynuu2p<*8L?_w#Mxro^I-w<^ti%{`5pA_N z&>s8{uWwi**g`B>tFT#2f@(S>6W0=AjyMof7kW)P^L~Thkcj)s%C)m-qu(fKTF{~#F|a&#iOg{-Og2Lklvq$s z?HMi#)67?)-o}X@(H|OFLYgbdut_LeXl5JB*(tv66;}^Q{)ym6#n&HM#m{2G?;`D= zv@1)DFwz&RMBg0!^hz7?O2y_}FxJZV;BRv3FZ!g^SGG=IW1+ECXG%27xL%3n$0Uz1 ze@A-chV@b*r{)dTbFD3Tonf!#GnScefRZsk=To^*o28JHEA@b24~FZ*;ri&m5@p<( diff --git a/out/production/KDTBE5_Java_ToyProject/me/smartstore/customer/Customers.class b/out/production/KDTBE5_Java_ToyProject/me/smartstore/customer/Customers.class index f14a047d0c7d2ac7696b023df0c3cf5785f36b1f..b162c7df2cde21c64db603dfc1660454d8688c33 100644 GIT binary patch literal 2517 zcma)8TXR!Y6#jN@r#+mOTT|#wE(L4|5K#ox;z$yx4nvFw_~EIkhl#QsmtGYWdnDq4=2XPaoh zX)k$#cC#jFc!ycd*}0_-rhz@!Yv3R<271tIpbsx7?Dg|y9c@=?u=!g{ z+_LY#pv8q-`Zmn1hM`SO%uJjgO|#)^4!kMNI#$H`sAA?>Q*>Z`b}=4CFf%>Nf->IJ z(R6#}ORkxpw+l>KYM3=0vtYTFvvCa#myK#@IC!*o&)UTrew0o5r*+ds*UDKALAI|` zDzw-|H)G~2Ol#-bY-i0|ye-rc*^^t!_2$c&ZrrQESO)v}ns)P@4q%5cpOP-*=NzJr zw*oAjs}xs?vvK$V)ZvE+e1qUuTnDh9V>^Q07{V5Q+tDwcHGdrN&{}!94%M-Sxl2AB z_YnF8ZQ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K}0G7=dr$p43SU}YWX!AVBE5FI3W z8IdZL=QFwjfcVNg!JT-tw&T@2kJOpBqjM~T|knDd`;{pU65Wkd=0gw0+uQ2L?Pi!&YFl$xFHb%?m$Zr(w&q)_h;8ze6`~b)L!+*m67kBSqsdEQ& V;T_C}d+8(5DM!txG49M~{sx~|6aD}I diff --git a/out/production/KDTBE5_Java_ToyProject/me/smartstore/menu/GroupMenu.class b/out/production/KDTBE5_Java_ToyProject/me/smartstore/menu/GroupMenu.class index 2a0bc5c9ebc6478dbe6f1cabcbef1ef6cd805421..f2af535b617c0f61b17a760844c3d257972f8239 100644 GIT binary patch delta 1533 zcma)5Yfx2H6#n*o?Q_rF7cR#O#4Biq%LI2EYQhLY6vRXW(R`$)CCLrRf-BsLvVL zH{3D$@1YR@#rV|=2O1?dnzS~VC}nd!HgWg{6E~uny%ve6fz1Y54YV1Eaq>-UZf0`} zn|3d5#cc+*n7AExNNhFG!SPNL>u@KVyCm*5aF4_`qXYNy*?mlKKl43cVkRDBv)v+H zT^0l$m3YiV2u%jGfycREC-0wN?@9J{Nj$|hPcy_b7KN$Mi9Hrv=rYjFiO-p+$MbA@ zBwjG-%7iChlz2(vqVOKxSNH&R0)fhwmRMV?wLV%KiEV6YXiN0quz?R1KEe?LAM<)t z&y}fqzt^h^J>leQu|eSz98+juZxqJ_()4K~?HsE zNrw7K@AKu0U-Svzfa{b%NdMsr>0Xr=E~WWhN~5s2Z!}PgTSlu1>M*Td`YJJxvZ}Q3 zhw|oAEP?WYAUsG$0I9f)c20-@4Ur~cr`Gs$#eBWlpPI3d4i&|K8CYaP3S2&!)#G1A zS%3Mni#aQW>a%bjYEWzES5D?Lyn-7OIA8e2VL0fNW@7WyCM+d{y$OZu8KH=>5=nXu zme6S`;Vs1#WYa0O49h7Nfsl9I=?NJ`OF ziHC_!1{&8gT{WFVvDOysA*!vo5~~PkIksRmUBX5CcB~=KP2Z?3Mj!_Va1~WK7~%&~vx329iz^ z)(&e^2V<4f0PB%NQrDB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P&R`VT#kF@k>kmmr<<{}U8siL@lZQjW%$2Xk9y|T}h Vaoi`q`+eN3n8K6(W~-0e{sycy3uOQR diff --git a/src/me/smartstore/SmartStoreApp.java b/src/me/smartstore/SmartStoreApp.java index 1754c712..08e4bf6e 100644 --- a/src/me/smartstore/SmartStoreApp.java +++ b/src/me/smartstore/SmartStoreApp.java @@ -37,6 +37,7 @@ public void details() { public SmartStoreApp test() { + allGroups.add(new Group(new Parameter(null, null), GroupType.NONE)); allGroups.add(new Group(new Parameter(10, 100000), GroupType.GENERAL)); allGroups.add(new Group(new Parameter(20, 200000), GroupType.VIP)); allGroups.add(new Group(new Parameter(30, 300000), GroupType.VVIP)); diff --git a/src/me/smartstore/customer/Customer.java b/src/me/smartstore/customer/Customer.java index e34b3ba1..7947f94d 100644 --- a/src/me/smartstore/customer/Customer.java +++ b/src/me/smartstore/customer/Customer.java @@ -4,7 +4,7 @@ import java.util.Objects; -public class Customer { +public class Customer{ private String customerName; private String customerId; diff --git a/src/me/smartstore/customer/Customers.java b/src/me/smartstore/customer/Customers.java index 27437210..4c203a92 100644 --- a/src/me/smartstore/customer/Customers.java +++ b/src/me/smartstore/customer/Customers.java @@ -20,6 +20,19 @@ public static Customers getInstance(){ return allCustomers; } + + public Customer[] getCustomers(){ + Customer[] customers = new Customer[allCustomers.size()]; + for (int i = 0; i < allCustomers.size(); i++) { + customers[i] = allCustomers.get(i); + } + return customers; + } + + + + + // refresh 함수가 호출되는 경우 // 1. 분류기준 바뀔 때 // 2. 새로운 고객이 들어올 때 @@ -28,6 +41,7 @@ public void refresh(Groups groups){ // 고객들 리스트 불러와서 한명씩 Customer.customerTotalTime-Group.minTime // Customer.customerTotalPay-Group.minPay와 비교를해서 그룹타입을 지정해준다. // 지정은 setGroup을 통해서 한다. + int noneNum = 0; int generalNum = 0; int vipNum = 0; int vvipNum = 0; @@ -39,13 +53,16 @@ public void refresh(Groups groups){ vipNum = i; } else if (groups.get(i).getGroupType().equals(GroupType.VVIP)) { vvipNum = i; + }else{ + noneNum = i; } } + for (int i = 0; i < allCustomers.size; i++) { if ((allCustomers.get(i).getCustomerTotalTime()0) return minimumSpentTime; throw new InputRangeException(); } catch (InputEndException e){ @@ -188,7 +188,7 @@ public Integer inputMinimumTotalPay(){ while (true){ try { System.out.println("\nInput Minimum Total Pay: "); - int minimumTotalPay = Integer.parseInt(nextLine(Message.END_MSG)); + int minimumTotalPay = Integer.parseInt(nextLineNotUpperCase(Message.END_MSG)); if(minimumTotalPay>0) return minimumTotalPay; throw new InputRangeException(); } catch (InputEndException e){ diff --git a/src/me/smartstore/menu/SummaryMenu.java b/src/me/smartstore/menu/SummaryMenu.java index b3cea5d1..0571a44d 100644 --- a/src/me/smartstore/menu/SummaryMenu.java +++ b/src/me/smartstore/menu/SummaryMenu.java @@ -1,6 +1,24 @@ package me.smartstore.menu; +import me.smartstore.customer.Customer; +import me.smartstore.customer.Customers; +import me.smartstore.exception.InputEndException; +import me.smartstore.group.Group; +import me.smartstore.group.GroupType; +import me.smartstore.group.Groups; +import me.smartstore.util.Message; + +import java.util.*; + +import static me.smartstore.util.Message.ERR_MSG_INPUT_END; +import static me.smartstore.util.Message.ERR_MSG_INVALID_INPUT_RANGE; + public class SummaryMenu implements Menu{ + private final Customers allCustomers = Customers.getInstance(); + private final Groups allGroups = Groups.getInstance(); + + + // singleton private static SummaryMenu summaryMenu; @@ -22,6 +40,143 @@ public void manage() { "Summary (Sorted By Time)", "Summary (Sorted By Pay)", "Back"}); + if (choice == 1) sortByGroup(allCustomers.getCustomers()); + else if (choice == 2) sortByName(allCustomers.getCustomers()); + else if (choice == 3) sortByTime(allCustomers.getCustomers()); + else if (choice == 4) sortByPay(allCustomers.getCustomers()); + else break; + } + } + public void printGroupInfo(Group group){ + System.out.println("\n=============================="); + System.out.printf("Group: %s ( Time : %d, Pay : %d )", group.getGroupType(), group.getParameter().getMinTime(), group.getParameter().getMinPay()); + System.out.println("\n=============================="); + } + + public void printCustomerInfo(Customer customer){ + System.out.printf("Customer{userId='%s', name='%s', spentTime=%d, totalPay=%d, " + ,customer.getCustomerId(),customer.getCustomerName(),customer.getCustomerTotalTime(),customer.getCustomerTotalPay()); + if (customer.getGroup().getGroupType() == GroupType.NONE){ + System.out.println("group=null}"); + } + else{ + System.out.printf("group=GroupType: %s\nParameter: Parameter{minimumSpentTime=%d, minimumTotalPay=%d}}\n" + , customer.getGroup().getGroupType(), customer.getGroup().getParameter().getMinTime(), customer.getGroup().getParameter().getMinPay()); + } + } + + + public int forSortbyGroup(int i, int count, Customer[] customers){ + printGroupInfo(allGroups.get(i)); + for (int j = 0; j < customers.length; j++) { + if (customers[j].getGroup().getGroupType() == allGroups.get(i).getGroupType()){ + System.out.printf("No. %d => ", count); + printCustomerInfo(customers[j]); + count++; + } + } + System.out.println("===============================\n"); + + return count; + } + + + + public void sortByGroup(Customer[] customers){ + for (int i = 0; i < allGroups.size(); i++) { + int count = 1; + if (allGroups.get(i).getGroupType()==GroupType.NONE){ + count = forSortbyGroup(i, count, customers); + } + + else if (allGroups.get(i).getGroupType()==GroupType.GENERAL){ + count = forSortbyGroup(i, count, customers); + } + + else if (allGroups.get(i).getGroupType()==GroupType.VIP){ + count = forSortbyGroup(i, count, customers); + } + + else if (allGroups.get(i).getGroupType()==GroupType.VVIP){ + count = forSortbyGroup(i, count, customers); + } + + } + } + + public void sortByName(Customer[] customers){ + while (true){ + try { + String standard = selectOrderStandard(); + Customer[] result = new Customer[]{}; + if(standard.equals("A")){ // 오름차순 + result = Arrays.stream(customers).sorted(Comparator.comparing(Customer::getCustomerName)).toArray(Customer[]::new); + } else if (standard.equals("D")) { // 내림차순 + result = Arrays.stream(customers).sorted(Comparator.comparing(Customer::getCustomerName).reversed()).toArray(Customer[]::new); + } + sortByGroup(result); + } catch (InputEndException e){ + System.out.println(ERR_MSG_INPUT_END); + break; + } + + } + } + + public void sortByTime(Customer[] customers){ + while (true){ + try { + String standard = selectOrderStandard(); + Customer[] result = new Customer[]{}; + if(standard.equals("A")){ // 오름차순 + result = Arrays.stream(customers).sorted(Comparator.comparing(Customer::getCustomerTotalTime)).toArray(Customer[]::new); + } else if (standard.equals("D")) { // 내림차순 + result = Arrays.stream(customers).sorted(Comparator.comparing(Customer::getCustomerTotalTime).reversed()).toArray(Customer[]::new); + } + sortByGroup(result); + } catch (InputEndException e){ + System.out.println(ERR_MSG_INPUT_END); + break; + } + } + + } + + public void sortByPay(Customer[] customers){ + while (true){ + try { + String standard = selectOrderStandard(); + Customer[] result = new Customer[]{}; + if(standard.equals("A")){ // 오름차순 + result = Arrays.stream(customers).sorted(Comparator.comparing(Customer::getCustomerTotalPay)).toArray(Customer[]::new); + } else if (standard.equals("D")) { // 내림차순 + result = Arrays.stream(customers).sorted(Comparator.comparing(Customer::getCustomerTotalPay).reversed()).toArray(Customer[]::new); + } + sortByGroup(result); + } catch (InputEndException e){ + System.out.println(ERR_MSG_INPUT_END); + break; + } + + } + } + + public String selectOrderStandard() { + String standard; + while(true){ + try { + System.out.println("\nWhich order (ASCENDING (A), DESCENDING (D))?"); + standard = nextLine(Message.END_MSG); + if (standard.length() > 1) throw new InputMismatchException(); + else if (standard.equals("A") || standard.equals("D")) + return standard; + } catch (InputMismatchException e) { + System.out.println(ERR_MSG_INVALID_INPUT_RANGE); + } + } + } + + } diff --git a/src/me/smartstore/menu/customer/AddCustomer.java b/src/me/smartstore/menu/customer/AddCustomer.java index db3b8669..15a9405c 100644 --- a/src/me/smartstore/menu/customer/AddCustomer.java +++ b/src/me/smartstore/menu/customer/AddCustomer.java @@ -31,7 +31,7 @@ public void addCustomer(){ //Todo : update에서도 활용가능하게 함수화 while(true){ try { System.out.println("How many customer to input?"); - int n = Integer.parseInt(nextLine(Message.END_MSG)); + int n = Integer.parseInt(nextLineNotUpperCase(Message.END_MSG)); for (int i = 0; i < n; i++) { System.out.println("====== Customer "+ (i+1) + " Info. ======"); @@ -124,7 +124,7 @@ public String inputCustomerID(){ public Integer inputSpentTime(){ try{ System.out.println("\nInput Customer's Spent Time: "); - Integer spentTime = Integer.parseInt(nextLine(Message.END_MSG)); + Integer spentTime = Integer.parseInt(nextLineNotUpperCase(Message.END_MSG)); return spentTime; } catch (InputEndException e){ System.out.println(Message.ERR_MSG_INPUT_END); @@ -138,7 +138,7 @@ public Integer inputSpentTime(){ public Integer inputTotalPay(){ try{ System.out.println("\nInput Customer's Total Payment: "); - Integer totalPay = Integer.parseInt(nextLine(Message.END_MSG)); + Integer totalPay = Integer.parseInt(nextLineNotUpperCase(Message.END_MSG)); return totalPay; } catch (InputEndException e){ System.out.println(Message.ERR_MSG_INPUT_END); From cc6609ee893fdde9c3d9b1e8e43135967a6c856d Mon Sep 17 00:00:00 2001 From: ho30archive Date: Thu, 11 May 2023 21:21:20 +0900 Subject: [PATCH 09/11] feat : set SummaryMenu MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 깔끔한지는 모르겠는데 구현은 완료 --- .../me/smartstore/menu/SummaryMenu.class | Bin 803 -> 7524 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/out/production/KDTBE5_Java_ToyProject/me/smartstore/menu/SummaryMenu.class b/out/production/KDTBE5_Java_ToyProject/me/smartstore/menu/SummaryMenu.class index bcb7aa3ac9b3b9afd1071c7f4bdd9da846a0c60e..d3714259ce8f4f718d5abbbe545873ab261315e1 100644 GIT binary patch literal 7524 zcmcIo33yc175;A~nKzj{NHSrQKo~HAY$SjI#SoB$0HY*OhicK<`j|Yzz+@)Q0;FnN zEn2s#U0mx{YfWpdic3VTTldZGi{1Bq-&;k~|Gf8R=FKER?Dv^`bKhOg`rmWTz3+YD z<;R}_aH86*;mUG&aFvF4`T4xskGaxZgKK5_-G00W@0H&BG+gJy^*-F-!;L=NG|-y55Mx^*P`b)qT#n1e&@$lTxpGR!Mt7?k;TdzGXWsmu_ijr5uE zj6$%8c!;y@;XH*f44UasJe4-$5tHULHXWO#v?nn@+R81_xY?f>+G!@Y8#`m1nHEkP zk-dG!urv0qiN>SpwF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XgQ44k24~17@dz{O$i=n;lyKDTY_h>u74EES_7w8 zq)Q4(*DF$4^xZD{=A}}c#&7DAc-dg(jOP%|0CRH>dYs6yfr)cJ6D;1tsG+MX>Cjs4 z`c9fXNay!pAA^2BXAZD;K`x5QNU@)DCFDGZbP^|fS#aNi^R3v~pMz+>3!*yedI=pG z{2JD^jk=l;P@i!?n@n{zSO4q)O{GE`HdWGF+S8aD`m%PlPK=nuqID7yYY&>pH@9 zJ>j~6aNS6_ZX#Sa6Rukb*BylGR>E}~;kuo0-SwKo#ji&;T=)#5)Wdw}mJB(K8PXis zGKRh_EKmKVccJ15Y~?*=+tV#phTaUl#mT?2mIp@1pR*F{b&^=)&r%|=f~VnDC$H>^ zd=F2`kFtQ=iv{=?Px1S30uGVtew>I081aWJZ-eBi#1bo)6jyxAptoBY)a_)DRNpy7 z@d)aeH`QvKtIQVOjx=no^2`0#@u{6pv88M-YfJua<+Ubnw$$0TpfX1906=Empr^uo z z%MvST&ofXru$sJ!m*hforG*m41l+_{T+PBHrV>Z*Z>(Wmz-~tU$UlkN$Nv6dGd}7G zR9dm$ZAG14w|Cl!{Z`yQ^Y{29=VpC?Di>G~DDs-=V0u%LhmCO}4y#=<(o?>Lct!CM zN;rgi2f_N9xPl43C8_`kJ<}FYW~D;dY}4Rql+P&G&>BPJZkP;y#d?O8P$86>Ap_Hy z6@i&Q^#Re;ir0`&&_dPGgD~e9L8v)02z4hPgoa}V_bBXKeSeUsX3o+t1hX1P{V(vc P1#~$w3a*_cPr=*|pF=Zx From fa714fec68169f596464e73054c8b3702dc833c6 Mon Sep 17 00:00:00 2001 From: ho30archive Date: Fri, 12 May 2023 17:19:18 +0900 Subject: [PATCH 10/11] fix : GroupMenu --- .../me/smartstore/menu/GroupMenu.class | Bin 5552 -> 5926 bytes src/me/smartstore/menu/GroupMenu.java | 50 ++++++++---------- 2 files changed, 23 insertions(+), 27 deletions(-) diff --git a/out/production/KDTBE5_Java_ToyProject/me/smartstore/menu/GroupMenu.class b/out/production/KDTBE5_Java_ToyProject/me/smartstore/menu/GroupMenu.class index f2af535b617c0f61b17a760844c3d257972f8239..291aeb159f8d1fcf10af96484e16028cca9be23d 100644 GIT binary patch delta 2663 zcmcgtX>e0j6#ib5^t~pp3xQH8wge@WCX@=T6i}+{7D_F&qPRcgwM}gn(xeIq0RdOQ z#!M6eF2|8>aPgt zfk>s#uS@6|7pH^~s`apN?J}$kMzp$en>I(rcB9QQG$F6l7;VcMI*r%r@ptu)3sV;L z&(y;cf?>ZF>9#R`u?)A2!+67E?VmLnr7~VpF##p?iv4IaRGT~b0A5yc5QkK}f(oP9wtDn5RH!(NBPw3S zYbuW7bro-*LPFY@U@%f232UJ#dZZ>et3EXm#}vG&;w`+b;J8@dk&tC9l6x6>mL#Jv z(d(>6jf!`1Ld7jYdk-g!*@@Y)$#`GI2RNzVLj@lR&yN*+A|dgRXHc5yQ+d=qt(`Dt9(4c@+H37b|R@! zGVXGW>?1*8i%r++qHG(>z}ylUUyHiGH(qn(Nq!npVjmUOj@%t@;oibZGoo=Gt#ZLt_^Ps1~n1PQ>jJ9N@rSZVbkeB%?xLO!0QI)2vT4p z2}z`&7xBs9iHpd3nZih-S7PE(fm-GrVh!_{+#+0yW%O?3i@Aa0xE&gsZYJKu%{UGn zCs4yd@R`^POlnbWMzO{S?P5A##{_I_6afz(E(W-s;S!k4$v9B@GpP>rmT_YThRDe4 zfGoq^fm|uA9pipOf?$G=K_^uBgaJgWj3p4+rQRb*Y{Cf7b|ex6*OaYr4r(zb_UIcs zR!ZGj*n(b7rw=rnwc?Nkho81@20Myf_fmRXzFGbnQ4TNuw zS*V9?XT#vGn$nToRa22kxyB@!8mse&Mi)JmL5B`FSl(&mLXw#YMS+8seB4A)#``@Q zt>iD?Xiv>1f0;4CS{3?G&gW$d2vCfyEo7|4gmDS-v6O$0cN5m-gn0#dxt}~dz|$`b8631gMkvzj=4te|o9u`{F4o3%^ok}~rzjyM<$F-AB6A;l7C4#Pt zNSDVM>)nEkofx(g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{8Op+-OE87DP_7qZDm5#AH_Zzb!Z?ZNc`Ae8Ttur)frpGbM2O?{p+HF5oAE za%vS!#{#BfF>x$GIv>NKSjs+HW>QLEAS(v8BYmVD=|8*2(uTANDMZ1sZ!2%D$rLa; zM{QEvMpe|HfK+5Qx>By-=1M|XMF^`2VI3i?Cxi`zP{|(I!ppYuA>0NZwxbL?2zV!f z?!t2H#v1IwCcI6reW=2IvOd6v;~*~L5UwDI>o{Uk7|K$3(3u68&H^kCP@QV3lUP2f zlrU^)XIRzF@J5GPq_D#u)*_j;xDPi|?`c9flE^AwXCIL*J5dNVU_hIX2nkq05M zeTdUL3~_dcBy^#FGh9jw``m0iiiZ=;m-pW|4>UPsfGRa&a z=d0v=jhwHO@{KmifmY5kg#V4Rg)f1O-fVo&ubt7p#gF)ooxOqU1UA*1w7q4@ji%fq LQe(@?#=gG*IWL}4 diff --git a/src/me/smartstore/menu/GroupMenu.java b/src/me/smartstore/menu/GroupMenu.java index c9165f0c..d3ceb374 100644 --- a/src/me/smartstore/menu/GroupMenu.java +++ b/src/me/smartstore/menu/GroupMenu.java @@ -62,7 +62,6 @@ public GroupType chooseGroup() { } public void setParameter() { // 초기화할 때만 호출 가능 - //todo : end 누르면 이전 페이지로 안넘어가고 chooseGroup에서 리턴된는 null로 새로운 그룹을 만듬 while ( true ) { GroupType groupType = chooseGroup(); if (groupType == null){ //chooseGroup에서 end입력되면 null리턴함 @@ -79,12 +78,8 @@ public void setParameter() { // 초기화할 때만 호출 가능 } else{ Parameter parameter = new Parameter(); - int minimumSpentTime = 0; - int minimumTotalPay = 0; // time, pay 사용자 입력받은 후, 설정 필요 while( true ){ - - int choice = chooseMenu(new String[]{ "Minimum Spent Time", "Minimum Total Pay", @@ -100,34 +95,32 @@ else if (choice == 2) { group = allGroups.find(groupType); System.out.println("\nGroupType: " + group.getGroupType()); System.out.println("Parameter: " + group.getParameter()); + allCustomers.refresh(allGroups); break; } - } -// group.setParameter(parameter); // 그룹이 없어서 set하는건데 구조상 필요없는거 아닌가? - } } } public void viewParameter() { while ( true ){ - GroupType groupType = chooseGroup(); - if (groupType == null){ //chooseGroup에서 end입력되면 null리턴함 - allCustomers.refresh(allGroups); // 파라미터가 변경되었거나 추가되는 경우, 고객 분류를 다시 해야함 - break; + try { + GroupType groupType = chooseGroup(); + if (groupType == null) break; + + Group group = allGroups.find(groupType); + System.out.println("GroupType: " + group.getGroupType()); + System.out.println("Parameter: " + group.getParameter()); + } catch (NullPointerException e){ + System.out.println("There is no Group Parmeter.\nPlease set a Parameter."); } - Group group = allGroups.find(groupType); - System.out.println("GroupType: " + group.getGroupType()); - System.out.println("Parameter: " + group.getParameter()); } } public void updateParameter(){ - // todo : 파라미터가 하나도 없는 경우 설정하라는 문구가 떠야함, Try-catch로 end예외 잡아야할듯? - // todo : 파라미터값 업데이트 되면 고객재분류 해야됨 while( true ) { GroupType groupType = chooseGroup(); if (groupType == null){ //chooseGroup에서 end입력되면 null리턴함 @@ -153,7 +146,7 @@ public void updateParameter(){ else if (choice == 2) { Integer minimumTotalPay = inputMinimumTotalPay(); if (minimumTotalPay == null) continue; - else group.getParameter().setMinTime(minimumTotalPay); + else group.getParameter().setMinPay(minimumTotalPay); } else{ System.out.println("\nGroupType: " + group.getGroupType()); @@ -171,31 +164,34 @@ public Integer inputMinimumSpentTime(){ while (true){ try{ System.out.println("\nInput Minimum Spent Time: "); - int minimumSpentTime = Integer.parseInt(nextLineNotUpperCase(Message.END_MSG)); - if(minimumSpentTime>0) return minimumSpentTime; - throw new InputRangeException(); + Integer minimumSpentTime = Integer.parseInt(nextLine(Message.END_MSG)); + if(minimumSpentTime<0) throw new InputRangeException(); + return minimumSpentTime; } catch (InputEndException e){ System.out.println(Message.ERR_MSG_INPUT_END); return null; - } catch (IllegalArgumentException e) { + } catch (InputRangeException e){ System.out.println(Message.ERR_MSG_INVALID_INPUT_RANGE); + } catch (NumberFormatException e){ + System.out.println(Message.ERR_MSG_INVALID_INPUT_TYPE); } } - } public Integer inputMinimumTotalPay(){ while (true){ try { System.out.println("\nInput Minimum Total Pay: "); - int minimumTotalPay = Integer.parseInt(nextLineNotUpperCase(Message.END_MSG)); - if(minimumTotalPay>0) return minimumTotalPay; - throw new InputRangeException(); + Integer minimumTotalPay = Integer.parseInt(nextLine(Message.END_MSG)); + if(minimumTotalPay<0) throw new InputRangeException(); + return minimumTotalPay; } catch (InputEndException e){ System.out.println(Message.ERR_MSG_INPUT_END); return null; - } catch (IllegalArgumentException e) { + } catch (InputRangeException e){ System.out.println(Message.ERR_MSG_INVALID_INPUT_RANGE); + } catch (NumberFormatException e){ + System.out.println(Message.ERR_MSG_INVALID_INPUT_TYPE); } } } From 40057895cf9b5f9e87738edb077bcc2278d89eb2 Mon Sep 17 00:00:00 2001 From: ho30archive Date: Mon, 15 May 2023 16:32:51 +0900 Subject: [PATCH 11/11] feat : done --- .../me/smartstore/Main.class | Bin 520 -> 500 bytes .../me/smartstore/SmartStoreApp.class | Bin 3339 -> 3307 bytes .../me/smartstore/menu/GroupMenu.class | Bin 5926 -> 5930 bytes src/me/smartstore/Main.java | 4 +- src/me/smartstore/SmartStoreApp.java | 5 +- src/me/smartstore/customer/Customers.java | 40 +++++----- src/me/smartstore/menu/GroupMenu.java | 70 +++++++++--------- src/me/smartstore/menu/Menu.java | 5 +- src/me/smartstore/menu/SummaryMenu.java | 23 ++---- .../smartstore/menu/customer/AddCustomer.java | 53 ++++++------- .../menu/customer/CustomerMenu.java | 31 +++++--- 11 files changed, 109 insertions(+), 122 deletions(-) diff --git a/out/production/KDTBE5_Java_ToyProject/me/smartstore/Main.class b/out/production/KDTBE5_Java_ToyProject/me/smartstore/Main.class index c40e66fb9a0baebd244a1548468d31dcf3153710..512de613915b03e62880c62b6c71b9b6c67b33ed 100644 GIT binary patch delta 215 zcmYL?y$%6U6okLKch|AkV*URt5s6Bp5^trDNOW55K8i>Xg$M8~O0_t56?=-A^EWf6 z@MCAM@8bzChz=*=AjQe3sG{(3f z+Ag?@8@PkZKp=WD9{d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vIl10R9@V|1H_P}JIDIzmx*eok8YPBKfht2oa17}L!^p(mj6&gf;&LSFF%psQ0&Fl2= zh6FC-1S=R|r8p>4_2u)lFq=7~X{uWAs|t`V;q$4)(s74asB#`{ALKJEuO-TaVW=w)2D|DARAG=d>pT}0gEZJQuw^jODmin5j>q`1gT8`hh zyyHL1-DD`r5}B8k|M@P_d;-fg+rp6%g?I2wvnkCmhr@Nzz4+Nj4*Pk813ap5g*5S) zE-p$l6KPS8?L0{6{eJiR3eU6o9`soz9H$+PoRlRwbsbDB3C+X$WG8AeL4vF|<^vokYYMgjOsOsah_g zmZZ`!T9j$4p|na9wNpx|o!b47_=QHDLBtPvx$oU~-}%lv=Q~B+4tKL({ZUZ`^x~7> z?zM#0>RjfE&Q-4ITvrP$ZCy8P+|;?nZ5wrg=N*mqDn@guVoPu1F7-O|nWJ-$dW}f= z5UC8SIpV%f0}pIGw9y!#9@%)T;a1r}ZZ+KM4SB*-of@9$Jm*E}F>8TIi&Fm9;cBWW z*u1!JoL8mTHwV4sRcWLBy=G|&36j%WjK_;6e=8$hvY8SC9WhFZfDy7{Xhk#ORx+CL zSV?TgY9+RrIL-LRVAbSEGqqe$1D#2ZW%Oi;40S03SjHe$s1432&87}H`$U)gaaH?& zS0(DZGhG{{Qroz-?&`DAA?sf?YkV#J{8CDgcz{_%%6+vYTqC7r;UZgnt&hE6gRzgiyFbwQ|$Le;38@VOyxr6Riw`8Dr(qf8N9egYy~;KKj_ diff --git a/src/me/smartstore/Main.java b/src/me/smartstore/Main.java index 542c11bd..e254be45 100644 --- a/src/me/smartstore/Main.java +++ b/src/me/smartstore/Main.java @@ -2,7 +2,7 @@ public class Main { public static void main(String[] args) { - SmartStoreApp.getInstance().test() .run(); -// SmartStoreApp.getInstance().run(); +// SmartStoreApp.getInstance().test() .run(); + SmartStoreApp.getInstance().run(); } } diff --git a/src/me/smartstore/SmartStoreApp.java b/src/me/smartstore/SmartStoreApp.java index 08e4bf6e..ff589c03 100644 --- a/src/me/smartstore/SmartStoreApp.java +++ b/src/me/smartstore/SmartStoreApp.java @@ -37,7 +37,6 @@ public void details() { public SmartStoreApp test() { - allGroups.add(new Group(new Parameter(null, null), GroupType.NONE)); allGroups.add(new Group(new Parameter(10, 100000), GroupType.GENERAL)); allGroups.add(new Group(new Parameter(20, 200000), GroupType.VIP)); allGroups.add(new Group(new Parameter(30, 300000), GroupType.VVIP)); @@ -53,18 +52,18 @@ public SmartStoreApp test() { allCustomers.add(new Customer("test1","test1",9,90000)); allCustomers.add(new Customer("test2","test2",9,3100000)); - allCustomers.refresh(allGroups); + allCustomers.refresh(); System.out.println("allCustomers = " + allCustomers); System.out.println("allGroups = " + allGroups); - return this; // smartStoreApp } public void run() { details(); + allGroups.add(new Group(new Parameter(0, 0), GroupType.NONE)); mainMenu.manage(); } diff --git a/src/me/smartstore/customer/Customers.java b/src/me/smartstore/customer/Customers.java index 4c203a92..ebb038b5 100644 --- a/src/me/smartstore/customer/Customers.java +++ b/src/me/smartstore/customer/Customers.java @@ -33,25 +33,21 @@ public Customer[] getCustomers(){ - // refresh 함수가 호출되는 경우 - // 1. 분류기준 바뀔 때 - // 2. 새로운 고객이 들어올 때 - // 해당부분 완성 - SmartStoreApp 참고 - public void refresh(Groups groups){ - // 고객들 리스트 불러와서 한명씩 Customer.customerTotalTime-Group.minTime - // Customer.customerTotalPay-Group.minPay와 비교를해서 그룹타입을 지정해준다. - // 지정은 setGroup을 통해서 한다. + public void refresh(){ + if (allGroups.size() != 4){ + System.out.println("you need to set all Parameter.\n"+ (4-allGroups.size())+" more left"); + } int noneNum = 0; int generalNum = 0; int vipNum = 0; int vvipNum = 0; - for (int i = 0; i < groups.size(); i++) { - if (groups.get(i).getGroupType().equals(GroupType.GENERAL)){ + for (int i = 0; i < allGroups.size(); i++) { + if (allGroups.get(i).getGroupType().equals(GroupType.GENERAL)){ generalNum = i; - } else if (groups.get(i).getGroupType().equals(GroupType.VIP)) { + } else if (allGroups.get(i).getGroupType().equals(GroupType.VIP)) { vipNum = i; - } else if (groups.get(i).getGroupType().equals(GroupType.VVIP)) { + } else if (allGroups.get(i).getGroupType().equals(GroupType.VVIP)) { vvipNum = i; }else{ noneNum = i; @@ -60,18 +56,18 @@ public void refresh(Groups groups){ for (int i = 0; i < allCustomers.size; i++) { - if ((allCustomers.get(i).getCustomerTotalTime() 새로운 고객객체를 생성할 때 //cusotmer이 null이 아닐때 -> 기존 고객정보를 수정할 때 @@ -56,12 +57,13 @@ public Customer inputCustomerInfo(Customer customer){ String id = ""; Integer spentTime = 0; Integer totalPay = 0; - if (customer != null){ + if (customer != null){ // updateCustomer일 때 기존정보를 불러옴 name = customer.getCustomerName(); id = customer.getCustomerId(); spentTime = customer.getCustomerTotalTime(); totalPay = customer.getCustomerTotalPay(); } + while (true){ int choice = chooseMenu(new String[]{ "Customer Name", @@ -71,24 +73,13 @@ public Customer inputCustomerInfo(Customer customer){ "Back"}); if (choice == 1) { - name = inputCustomerName(); - if(name == null) continue; + name = inputCustomerName(name); } else if (choice == 2) { - id = inputCustomerID(); - if(id == null) continue; + id = inputCustomerID(id); } else if (choice == 3) { - try{ - spentTime = inputSpentTime(); - }catch (NullPointerException e){ - continue; - } - + spentTime = inputSpentTime(spentTime); } else if (choice == 4) { - try{ - totalPay = inputTotalPay(); - }catch (NullPointerException e){ - continue; - } + totalPay = inputTotalPay(totalPay); } else { return new Customer(name, id, spentTime, totalPay); } @@ -97,7 +88,7 @@ public Customer inputCustomerInfo(Customer customer){ } - public String inputCustomerName(){ + public String inputCustomerName(String originName){ try { System.out.println("\nInput Customer's Name: "); String name = nextLineNotUpperCase(Message.END_MSG); @@ -105,47 +96,47 @@ public String inputCustomerName(){ return name; } catch (InputEndException e){ System.out.println(Message.ERR_MSG_INPUT_END); - return null; + return originName; } } - public String inputCustomerID(){ + public String inputCustomerID(String originID){ try{ System.out.println("\nInput Customer's ID: "); String id = nextLineNotUpperCase(Message.END_MSG); return id; } catch (InputEndException e){ System.out.println(Message.ERR_MSG_INPUT_END); - return null; + return originID; } } - public Integer inputSpentTime(){ + public Integer inputSpentTime(Integer originSpentTime){ try{ System.out.println("\nInput Customer's Spent Time: "); Integer spentTime = Integer.parseInt(nextLineNotUpperCase(Message.END_MSG)); return spentTime; } catch (InputEndException e){ System.out.println(Message.ERR_MSG_INPUT_END); - return null; - } catch (IllegalArgumentException e){ + return originSpentTime; + } catch (NumberFormatException e){ System.out.println(Message.ERR_MSG_INVALID_INPUT_FORMAT); - return null; + return originSpentTime; } } - public Integer inputTotalPay(){ + public Integer inputTotalPay(Integer originTotalPay){ try{ System.out.println("\nInput Customer's Total Payment: "); Integer totalPay = Integer.parseInt(nextLineNotUpperCase(Message.END_MSG)); return totalPay; } catch (InputEndException e){ System.out.println(Message.ERR_MSG_INPUT_END); - return null; - } catch (IllegalArgumentException e){ + return originTotalPay; + } catch (NumberFormatException e){ System.out.println(Message.ERR_MSG_INVALID_INPUT_FORMAT); - return null; + return originTotalPay; } } diff --git a/src/me/smartstore/menu/customer/CustomerMenu.java b/src/me/smartstore/menu/customer/CustomerMenu.java index 082eeba1..5aa5e758 100644 --- a/src/me/smartstore/menu/customer/CustomerMenu.java +++ b/src/me/smartstore/menu/customer/CustomerMenu.java @@ -47,16 +47,21 @@ public void manage() { public void viewCustomer(){ - System.out.println("======= Customer Info. ======="); - for (int i = 0; i < allCustomers.size(); i++) { - - System.out.printf("No. %d => Customer{userId='%s', name='%s', spentTime=%d, totalPay=%d, " - , i+1,allCustomers.get(i).getCustomerId(),allCustomers.get(i).getCustomerName(),allCustomers.get(i).getCustomerTotalTime(),allCustomers.get(i).getCustomerTotalPay()); - if (allCustomers.get(i).getGroup() == null){ - System.out.println("group=GroupType: null"); - } - else { - System.out.println("group=GroupType: " + allCustomers.get(i).getGroup().getGroupType()); + if(allCustomers.size() == 0){ + System.out.println("No Customers. Please input one first."); + } + else { + System.out.println("======= Customer Info. ======="); + for (int i = 0; i < allCustomers.size(); i++) { + + System.out.printf("No. %d => Customer{userId='%s', name='%s', spentTime=%d, totalPay=%d, " + , i+1,allCustomers.get(i).getCustomerId(),allCustomers.get(i).getCustomerName(),allCustomers.get(i).getCustomerTotalTime(),allCustomers.get(i).getCustomerTotalPay()); + if (allCustomers.get(i).getGroup() == null){ + System.out.println("group=GroupType: null"); + } + else { + System.out.println("group=GroupType: " + allCustomers.get(i).getGroup().getGroupType()); + } } } } @@ -65,13 +70,14 @@ public void updateCustomer(){ // 고객객체를 업데이트 할 때 기존 정보를 불려와야함. viewCustomer(); while (true){ + if(allCustomers.size() == 0) break; System.out.printf("\nWhich customer (1 ~ %d) ?", allCustomers.size()); try { int num = scanner.nextInt(); scanner.nextLine(); - if (num > allCustomers.size()) throw new InputMismatchException(); + if (num > allCustomers.size() || 0 > allCustomers.size()) throw new InputMismatchException(); allCustomers.set(num-1, addCustomer.inputCustomerInfo(allCustomers.get(num-1))); - allCustomers.refresh(allGroups); + allCustomers.refresh(); break; }catch (InputMismatchException e) { System.out.println(Message.ERR_MSG_INVALID_INPUT_FORMAT); @@ -85,6 +91,7 @@ public void updateCustomer(){ public void deleteCustomer(){ viewCustomer(); while (true){ + if(allCustomers.size() == 0) break; System.out.printf("\nWhich customer (1 ~ %d)? ", allCustomers.size()); try { int num = scanner.nextInt();