From c17f42178282325e124735d363678895b4de7fbf Mon Sep 17 00:00:00 2001 From: AlessandroBorr Date: Tue, 21 Nov 2023 11:34:31 +0100 Subject: [PATCH 1/5] ATM 1.0 (5293937) --- .gitignore | 24 ++++++++++ bin/ATM.class | Bin 2920 -> 0 bytes bin/ATMCaseStudy.class | Bin 456 -> 0 bytes bin/Account.class | Bin 1146 -> 0 bytes bin/BalanceInquiry.class | Bin 1116 -> 0 bytes bin/BankDatabase.class | Bin 1450 -> 0 bytes bin/CashDispenser.class | Bin 677 -> 0 bytes bin/Deposit.class | Bin 1997 -> 0 bytes bin/DepositSlot.class | Bin 343 -> 0 bytes bin/Keypad.class | Bin 535 -> 0 bytes bin/Screen.class | Bin 910 -> 0 bytes bin/Transaction.class | Bin 812 -> 0 bytes bin/Withdrawal.class | Bin 2489 -> 0 bytes src/{ => code/Buisness_logic}/Account.java | 1 + src/code/Buisness_logic/Euro.java | 49 +++++++++++++++++++++ src/{ => code/Database}/BankDatabase.java | 3 ++ src/{ => code/Database}/Transaction.java | 3 ++ src/{ => code/GUI}/ATM.java | 4 ++ src/{ => code/GUI}/ATMCaseStudy.java | 1 + src/{ => code/GUI}/BalanceInquiry.java | 4 ++ src/{ => code/GUI}/CashDispenser.java | 1 + src/{ => code/GUI}/Deposit.java | 4 ++ src/{ => code/GUI}/DepositSlot.java | 1 + src/{ => code/GUI}/Keypad.java | 1 + src/{ => code/GUI}/Screen.java | 1 + src/{ => code/GUI}/Withdrawal.java | 4 ++ 26 files changed, 101 insertions(+) create mode 100644 .gitignore delete mode 100644 bin/ATM.class delete mode 100644 bin/ATMCaseStudy.class delete mode 100644 bin/Account.class delete mode 100644 bin/BalanceInquiry.class delete mode 100644 bin/BankDatabase.class delete mode 100644 bin/CashDispenser.class delete mode 100644 bin/Deposit.class delete mode 100644 bin/DepositSlot.class delete mode 100644 bin/Keypad.class delete mode 100644 bin/Screen.class delete mode 100644 bin/Transaction.class delete mode 100644 bin/Withdrawal.class rename src/{ => code/Buisness_logic}/Account.java (98%) create mode 100644 src/code/Buisness_logic/Euro.java rename src/{ => code/Database}/BankDatabase.java (98%) rename src/{ => code/Database}/Transaction.java (97%) rename src/{ => code/GUI}/ATM.java (98%) rename src/{ => code/GUI}/ATMCaseStudy.java (98%) rename src/{ => code/GUI}/BalanceInquiry.java (96%) rename src/{ => code/GUI}/CashDispenser.java (99%) rename src/{ => code/GUI}/Deposit.java (97%) rename src/{ => code/GUI}/DepositSlot.java (98%) rename src/{ => code/GUI}/Keypad.java (98%) rename src/{ => code/GUI}/Screen.java (98%) rename src/{ => code/GUI}/Withdrawal.java (98%) diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..524f096 --- /dev/null +++ b/.gitignore @@ -0,0 +1,24 @@ +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* +replay_pid* diff --git a/bin/ATM.class b/bin/ATM.class deleted file mode 100644 index 76543bfde35c4daa304c3934c927eca8f833d61e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2920 zcmai0Yi}FJ6+J`JCcRp}l-h|U*QHwj0NitX9^;WbTCUZ{!yU2=XBTDhjB9elGem`Um=<=$9g?duEr6)ggHOaN9+>3!l-(FkR z*Jhl0O}RWnV1I5p>fjq)WmT)z9lubi63X7(%+8civn1X18R^TCtSfWB%bB6PzVF3 zVd>DIi9Ilqc#fe^4+H5ilrhl-Gl>xmH>!t$;qZ;~CiY@q65pmk5k(AK2;(o9*pCBA zj8USfBnB>pFI+Zp5ZzjE$5mnGin3IphTXZUEh|gXbM(CJO!#X~U0_#^WkOlwUc*gc zMqrPztSWYOL-lK3b0)6h8n-AjqZQfAt9o6oDt&~&p@G~^X%&3WaaYF&mkcWLJrghD zC`(U9YU~Esj2!Y zT)~(2dS2E71}PK-P8y39#X7NAv&z#8JWGbPYq>%3j#-+<4HHY6#=a+M==8j7Vg)Sy z)T;8cZmq$RWEEsn_yMnpF}t(xVs>6{b_uU)a<5Ukfoyj0l@z4FNY=eAD^B?vhg((8 z;Fi7qN=q|s=LZ=_$r0h1r8gtcO9SEv)B-6WDk^bqCVN>eh2`qfN5V*)fGC zaT|I1tqrmtOW{pc%&0YFEjj9rwb8Unk}b_9gP(ANa||py{#x0ScP!n3Qh1B*^K`c_ zlXbJ2mdcfI|E&9Z!||F1?%}>}2k!~= z3}ib!@X78pxRk^%b?<2-kre|E@V;L5fxzhhTGnZv-{_Qjw~ut+3j3ph5AiF#)vpDH z|L<0j7Q#Epp5`}eys`rqC^yzsI=4$3!DI z&ZW0;JRRRczy3LyeuUF2+c>j@0h(!=XSXm!bC~An7S7SUK=b)6T%>u4=J*ySz6dZ) z^7mQxY2XkNc$(HTWO9UmJvfD4w&OmG5y31Ge1~tDAp(3CQ=AE0`5N83R7ay5-Nb?P zA2HB9-NJ0Tg)AripFI9M&0GYueq(`eY(D-Q7sasy~{$2TJdH~BROetOzy{=wC{%xWUvtJAQ~ zN2AleBYZ~qEIh)!6@omef%2Ky#xL@ln0$l>Pq-Nx;&W~r4;eoG2p|5p@WpL>oIm?{ zaE87(VL84-Hurd6@AI;}$2{HV$q#TI4~hSM=H($4@ByylBfQF9a*Lyj-$u%@*5*bg h_ze{o+)uyJ;Hb;73yCk$$E+Ma*301U=!)U@{{e#?XM_L% diff --git a/bin/ATMCaseStudy.class b/bin/ATMCaseStudy.class deleted file mode 100644 index 607c10d4dd7fb15304bfa8a9ae6744532e8a1e0c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 456 zcmZut-AV#M7(KJDuDhLH!=Ros>RsS?-;=L0$I$yl5IZ)hiDy$~pc z+nz1z&7_V5YW3%EQFxc;f4b4!b6+V9lN_k$+pQJ)&6yHVQ<4eSx*e z&P54jP7L{uVis%h6T#DxpL70>>PDora&(c0M{;2$R$CKL!#;_5CON<%gifW<(4o(MiXYI# zn3S0K;0O3o#&yn&1S~Ie_St8xwf9~de*gLT3&1Npi6JBqdt=+9$E__!-zdLvH`W~t~)cj$Vr zS*X@(?e5k)0>;j$=OhqD+C&l=>ecFEa?p`uSKWi8;T^l@0`Yb*;0t!_9XrA8-#AgGKD71)a_a5cKxt-=7UoG_ z$bs9Fp3gFBt@YWC$JIVieNRZE{toCEQ^Y;d=#lgKiFpQ7E%)T_N`s5#us^$$OYJ zz

T;7_HB5OUX6VgUUOURLv)?k5|~J+6%rW^bA{^sWCTGayC;E7M>Tz>% diff --git a/bin/BalanceInquiry.class b/bin/BalanceInquiry.class deleted file mode 100644 index 48f8e6aac7e4689adac3e3b62b94bed3ef9ca787..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1116 zcmZ8gTT|0O6#f=kQbOd?3UUz$7qx`~UJ#{Rv`}&C6kq7@z74TP(?pY$k)P#Do$EuXZH8&lMTTh79e!!nr`|*uSuK3}V!!fT#)#%c#|* zA&|Ky#CkmLWyRL|Sqfybga|Z5Xo)ieb zrl1p;OhrK!4VYMBLxkKS&!SZwD|nz`Rlw-2XW$_o3FK7JrF2|1pkyE%ZN6HlsKA1O zH3d^_>wYBN1d>5fU{X(ZX4U)P2Q8`8E9uz8V+~uBu}jjx6Fj9B7f$%al~<>B7|N!t zv|@^U?UTHeTNI+XbruDV*QB-?Yzs`88|HszW}~ZB$yDig47^Y&NBdK%t6c*nP|93# zRqpj28N3qUP>n{a6W6eie4mISA0Cs}qDbC|(A*9sO;z#`=_ yvCY;?SjKCfsy4P6MKVbnY3%bRN2)p{F2`-;76YgP0v*zItMy8-B4FPrPBtH-0_K=s@q-BgBb}KS zh@Pu1c{U7mIitPuuXr_q7(31^+H7yc!A|T_S`Irnf};YRtFr7b5qhmKLz5|aQJ|;J zys(cyS}YaQpw70x0vlB`tI{tkd!{5u>(Vtvlvj1mI5-J9!y)ErFTr!wK$b(GLQFUq zQwY3$hB|lK8OAan5ls#Lm*Ie&{ug2EX zKAD4R>#&OkaNay4YE^i%c;_zhjPtb$Wf3rzeGNMsdk5zg64{qX7;oV$^c*^!>`tL4 zg^jP#JFDVR6;EzXZb@M)KNWt#{0O%3>|+g(H;PVbRFm(*C=wW8)M?hicI?o2&Lq_E zkl9LEM)5D4iM>A&H71^*cS~&G$n;PHyZav@HuU_yAqIM*kAHm^&j~i#3Z{_4CcZb5 zJca$}*9CX##xr3-(qkY02_kHy`HCP*o?aNgumL7*p~u3)0U!|}YzV`lzJSmup~-B2 z0|#e@KO#Q7t${;Nji)UkNsSm}ANxqZAKfgVy3RH;TOyJ;rbUnq$9YqoJ2*kKq2+Kc zKhSMyw@%_zs9>D92-)IVK?A3s@zJ#0Bm@}I#rm3{Ri9pX&LS78 zDpIrZ#n!6Q4NR_Wf~}>Dau>$hhGDm)*)1Pz+)}+ CIN&V+ diff --git a/bin/CashDispenser.class b/bin/CashDispenser.class deleted file mode 100644 index b8cedbabb217701eda2172f78400527c77edff6d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 677 zcmZva&2G~`6ot>kPC`>Bj??f{no`)6Ea(G3D^)>AmO?6#5D7MD;!N8qu3h}o_hH`+ z5>=%x`T#snmk4pjwkj&I8PB=C=YHo}{`Kej2EZ$Q?EzmuY z=W-{M(b3Mq;zR`*yZnhi^Y_PJMh71!GXdcnXB?%OjIy~5b7cYIR-hilc|=3wjgEA- zCtz*AoD0~ac&S>j&~ebh>Iz74u!4qwJJyk!*=wr_w9d0GZ(FLW5DAJn&8Cu%9MuG49Lc&G!dqRd$K&!rAau4hz+H`c#Go58W*3hRCc!)>UtU0?4ySvfthr7d1Kj99R z|CzVOWPP}Fnt9JlPc@HjJT7wANqoYa$+ymJ%DhL^hT)YAgZPfRePLa&Xu*W;F)oVr h2aLT*(AGa7?+)bMft(7oK_5TaZ@B!eFrcbo^DlP^aK8Wm diff --git a/bin/Deposit.class b/bin/Deposit.class deleted file mode 100644 index 57b0c3f71f0c14c3e68bdbb1340a34a706e145a4..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1997 zcmZ`(+inwA6kU_Vu`>)Im;?w3^w0~~#&IYuq$J#oowNogq}X*EdV!PiAsI56v1Z1h zk^0i7enLeho_R!-N-FiCAJ9*#RMd6GV@N7hmd59@_daW_efjJ4AAbV44mXVf1L>;j z_@NV}F=XISGmu^=?a1*x1H*FL?|P8|qsq;e+U>};flU2wyjq}nyXV_*eOeu^C!zF~ zx0yNP1CAx?MF$2w>D}j^{)-49w!pE_&J+sg>^bx(b?d z-Bkv%b>Eh5O9qbKCx=7PrV|<%=_4Suquo#iW!u*B^aAi+M%z6GTBC#uAK~$SLIy?; z66|^QH034D_sPiosPC2CjRdBH0)M*`E%`wLp_~)|pRQ`X1w>Vg?UiO(Y6zIT)Dff!ccCI zjVPe=f~Gx(>lSX{rh#LLOVxK>8T1hj<*NBs24&V-Nn2MeRP_VdgAeG8n^?kUX?)81 z-KVsL8t%~E2^SOm_m!=j9mSF-{RbJ;4Lmp3{BH1;;ie45I%`%0iEYVTxz}8r7tKv2 zwtY|SiYMJL>Pw^A;;G}h!t*1#3G#GYU1)-3rz5rWl zm<`x=*vhF~Etc~u19voK(RSJ~>VC4lHyRX0=*M`=&1IqWu%%}!mq=rP(c6Ji%HV;4 zNwX3g=&IO%St=3J`o7L5oG=~;B-1acw<$3g>Tn~H_SUlO#EqJPG%(+{N}rN>sv(FX?1 z29sc`B}WerE2*ZEE?}IcnI3XO7|=b#)qtKq@js^z|4-o%ELt6o&qis@p2irzM|tuC zJ+;?(VX8RuJFD3v$Lo9kFh*D!5$Gb$PBaP!dVoMRj`}m-T#2Da>zI#;I!?`*?h2;XjrB}FA_zjmv ze}0B?G5hfzt`zlt57&y>TYI?8&51oM-Z=dXCyUv;Jh?!(<(|#wFOV%}zvSTyj1;qL zTxeE<(5&u|7l=JY^d|9UiF1mGritkc|Igwa@;HxK6xixBSm3IR%UH%0tl}zKxP~>{ z#6zBHH3~iai5e+<&7aPXNy~3yHRkyJ7T@vxhqNEV;A^a=aX*bY<8NeA)QbZ$$;^+8 zrd1PKiu#4@BQhtci9M`epZ*1@(U;Rdjbp=qNt+&@Q*kzy$fw4f-({9oaDsh0$!^s6 iL@(YOd{Z$hjymSlVcrH}R2;znU{XUOkSBB-z}CO7AjkIr diff --git a/bin/DepositSlot.class b/bin/DepositSlot.class deleted file mode 100644 index a2664ad97f3f37ceedeef3f28138881cd983b39d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 343 zcmYjMyH3ME5S(=`F*pe^`2#vY2!8;NhDT*357J_@mC z5V)Dyxt+P){rr0W0C0h6h=4G>=8dh5TNKuXP=t7`8=Vxod`#xqnsY}OoSV|POG5AP zXh~34cEu5T*d3vd0b!Dwl4slJjH`Q{6-=0>HrK^cSH|n#N9CSOO&F)0k!RvH^-bAu zVK;ooIh%%8?W6}nw6NPM=Ue0dj61PYza$PIM!5wDq>@zxLs5w^3HOiRu=CosBSGH= l6o!JMAA|5%6k!h&K_5O5_P#*9c*K7)>Li1|WZb&;zX8_XJgxu$ diff --git a/bin/Keypad.class b/bin/Keypad.class deleted file mode 100644 index 9b066e220ca842b7787e1c6ebbcc07d61efe2393..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 535 zcmZut%TB^T6g^WOEw#KweByHfEF^J@x-ps%i7skLTn;e7A*Cgy82KkR8kIy7KfsSN z-YLXrbTe}w=bU@*`S^T&2XKTv9U4RYTug?%t0T&g>GNA&bGX~9UAFt86EMW2I~>!W zZ-%{bAf1}s;jSzEI*|{hD}!T(NV(Eth@N;|VIqPB3pxxPNrvnnUIJ-kb!2|cvnQiK z3@qf3XV9d}P?$}WUag^4umfN4LEVIff>K{%ST6qysk9QHriB>d4C$tH#l?8g7XB4) zJAxtC^g7&WabK!@UW^7ea>QUXXLitSMo$FcKm-IhTmpq_fNgCBB6ko7;Pq7B26A$aTAAIARzZ0T%zW`@jWi$W) diff --git a/bin/Screen.class b/bin/Screen.class deleted file mode 100644 index a03675802694ce60d6bb59226365236d62e87a7e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 910 zcmaiyU2oGc7=@49v}v#JAsWT?V7a_A|6S}zz$Zy-Zgud|;< z^xmBclzQoD9f6Dc?)1o$Cp&67m1FvxM(^zSeiXX?xYHbzaS4kiYIEWGC(}qxY+Q!J zU_s2BPHJ|8_G>yL`jwn?EL_1g6ITTm6ZZVJjq9ig6ppk*z?}SwQu{Lr>zWU&>(=-? zHtuSQnNU2RM`glp;CV89J_%w?HyYjMpoA5+bY*q3wRK?OJ{l(0<|^w3F`H(iiFG26 zr5CH+1Kpc$b0$-&N~+tm@c=DCljAAf{!1I*&3My`?PR$5hVWX7GRrHv0#-kW!;yOF z>U&*CudbyVi6yY{d_{o4FTMnhCRc6Ff^%X06G|WWk%PriZ)@oSM>`d8zQ7e90xBG} z`5DzY&ZUp2Zk(ci=C_jnWvZ-%QBQRlgAUxlO;QAI{fl<{Jgq`n^*^*FEN9tvsMZBL q%vQT+d_{gQzxElc{ZnkbJ&$(yGV3#F=XX$t9eS7qeMDFeTR#DnORnGm diff --git a/bin/Transaction.class b/bin/Transaction.class deleted file mode 100644 index 1330b55e97b38711f909025f939758b75d82a158..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 812 zcmZuv+iuf96r8o4q)FUdnl?bMP;Q9@RFg76$`BRX9apK;07}Od?>XHWTpf<{)bA;di_ll zNBW(>=ID6Ay7^{26>tuckE#V5T^DWi1nkjx+JwNGiyG<%t-EMo#h{^!CRzerKZ;eU z?_35mPG9qrP|l_@jZA!b&uzeERf}(!?kvK_Ao#n z_nGxdJ|19`5j$avb47u+IoT@E4rklU?qctH@`Sf}Rr7wL|Bb+c8C6n;MQbC{2rgR- oJcO}lWLL?9?@Q$EJIVWadk(n6d&&EH=80P1>+goQ$T(al+exLike!egL^Tn^f12~R* zDgp|$i07 z)zD3u0-+w9A>P0j~*|J{_kdcwIU| z2up=-9Y>@>lr}4X&~OxQs5nNr%1);o|wb;F(SZYW@b{uDPyb1QQ zE)$eJD^2*C6A_$M(5#&+nCv>k6|<(XR4kW_97PPfxR}r|f{cn$Hm#4Dj&nHAj#)>` zam2JKJBqCqOJ5fYqMf--w~x6c%bxCw)5n;Cl$Nrc^(1`z6!pCBvV~L1fNWZCSU zMw@YQoAJ6O=gPBVafE6VcjC#lIiRqcb(i3Ux{2nL1Pa&Kb_6FM8LhaS4*xT zy12goRzdAGWS!@A+>o{1URhfW4$3OnQ(=Epbu7sKkFcRr_I%lm;HEU6S`Y;*Z#ZVb z^j2xY7%wduVp>=>q15EwU<8)zdeyHb$18A|of)#E85OrFHpceLnWrtemTEUPPeL{p zUg7x39U4SHP9v#+TyEaY)y8`dw(*_i@ZM@D&3sVHGs>4c)RbEFEzPZMzhFm8Q}8*N zrqFXVKJzqo^Q@y3u#=V>QG;EicB6?eCwyJ{XeLK1c**l6sl9lau}Eqk3@^rdMjP=g z)nh+n3o(XQalns6`F=H$2UYzo%XqCf$TQv>YT?!P9Gxvcqca+Qj4Ms@!{KH0q~z0s z*w>G6id3WImeKzZF<-*_x{Se%Z>NL(O`*ECmXUsneWWgUR0FATkJ?6Rg4DC-hby1S zwVA@|6AT)-z7-vsW1Rd56N81G<`V8wBsJ}xt!`-IS^ zBDhPR1|i&zCA>%IL-Y@}aA<{3VHJu3mhY&_C#>KiLh`9orSfA-ed%t57S6C(Bbdb)3WVLJ)D3)& zoA`nNe~H`pinH?#KEStx{t@r*DDeazd8O<2ky$U@6Y9trRPop=PJmwTvFNuMQHfw;mlsd)cyES|KkpGCMgRZ+ diff --git a/src/Account.java b/src/code/Buisness_logic/Account.java similarity index 98% rename from src/Account.java rename to src/code/Buisness_logic/Account.java index c308eca..07d00f0 100644 --- a/src/Account.java +++ b/src/code/Buisness_logic/Account.java @@ -1,3 +1,4 @@ +package code.Buisness_logic; // Account.java // Represents a bank account diff --git a/src/code/Buisness_logic/Euro.java b/src/code/Buisness_logic/Euro.java new file mode 100644 index 0000000..7e95e86 --- /dev/null +++ b/src/code/Buisness_logic/Euro.java @@ -0,0 +1,49 @@ +package code.Buisness_logic; + +public class Euro { + + + private long valore; + + public Euro(long euro, long cent) { + if (euro >= 0) { + valore = euro*100 + cent; + } else { + valore = euro*100 - cent; + } + } + + public Euro(double d) { + valore = (long)(d*100); + } + + public long getValore() { + return valore; + } + + public Euro somma(Euro e) { + this.valore = this.valore + e.getValore(); + return this; + } + + public Euro sottrai(Euro e) { + this.valore = this.valore - e.getValore(); + return this; + } + + public boolean ugualeA(Euro e){ + if (valore == e.getValore()) + return true; + else return false; + } + + public boolean minoreDi(Euro e){ + if (valore <= e.getValore()) + return true; + else return false; + } + + public String stampa(){ + return (double)valore/100 +" euro"; + } +} \ No newline at end of file diff --git a/src/BankDatabase.java b/src/code/Database/BankDatabase.java similarity index 98% rename from src/BankDatabase.java rename to src/code/Database/BankDatabase.java index 3978497..d4d3509 100644 --- a/src/BankDatabase.java +++ b/src/code/Database/BankDatabase.java @@ -1,6 +1,9 @@ +package code.Database; // BankDatabase.java // Represents the bank account information database +import code.Buisness_logic.Account; + public class BankDatabase { private Account accounts[]; // array of Accounts diff --git a/src/Transaction.java b/src/code/Database/Transaction.java similarity index 97% rename from src/Transaction.java rename to src/code/Database/Transaction.java index 508fea8..f1fe993 100644 --- a/src/Transaction.java +++ b/src/code/Database/Transaction.java @@ -1,6 +1,9 @@ +package code.Database; // Transaction.java // Abstract superclass Transaction represents an ATM transaction +import code.GUI.Screen; + public abstract class Transaction { private int accountNumber; // indicates account involved diff --git a/src/ATM.java b/src/code/GUI/ATM.java similarity index 98% rename from src/ATM.java rename to src/code/GUI/ATM.java index aa3d187..244c47a 100644 --- a/src/ATM.java +++ b/src/code/GUI/ATM.java @@ -1,6 +1,10 @@ +package code.GUI; // ATM.java // Represents an automated teller machine +import code.Database.BankDatabase; +import code.Database.Transaction; + public class ATM { private boolean userAuthenticated; // whether user is authenticated diff --git a/src/ATMCaseStudy.java b/src/code/GUI/ATMCaseStudy.java similarity index 98% rename from src/ATMCaseStudy.java rename to src/code/GUI/ATMCaseStudy.java index b9033bd..5beedde 100644 --- a/src/ATMCaseStudy.java +++ b/src/code/GUI/ATMCaseStudy.java @@ -1,3 +1,4 @@ +package code.GUI; // ATMCaseStudy.java // Driver program for the ATM case study diff --git a/src/BalanceInquiry.java b/src/code/GUI/BalanceInquiry.java similarity index 96% rename from src/BalanceInquiry.java rename to src/code/GUI/BalanceInquiry.java index d45fa6a..2162c17 100644 --- a/src/BalanceInquiry.java +++ b/src/code/GUI/BalanceInquiry.java @@ -1,6 +1,10 @@ +package code.GUI; // BalanceInquiry.java // Represents a balance inquiry ATM transaction +import code.Database.BankDatabase; +import code.Database.Transaction; + public class BalanceInquiry extends Transaction { // BalanceInquiry constructor diff --git a/src/CashDispenser.java b/src/code/GUI/CashDispenser.java similarity index 99% rename from src/CashDispenser.java rename to src/code/GUI/CashDispenser.java index b249faf..4e95de8 100644 --- a/src/CashDispenser.java +++ b/src/code/GUI/CashDispenser.java @@ -1,3 +1,4 @@ +package code.GUI; // CashDispenser.java // Represents the cash dispenser of the ATM diff --git a/src/Deposit.java b/src/code/GUI/Deposit.java similarity index 97% rename from src/Deposit.java rename to src/code/GUI/Deposit.java index 916ef70..e68152e 100644 --- a/src/Deposit.java +++ b/src/code/GUI/Deposit.java @@ -1,6 +1,10 @@ +package code.GUI; // Deposit.java // Represents a deposit ATM transaction +import code.Database.BankDatabase; +import code.Database.Transaction; + public class Deposit extends Transaction { private double amount; // amount to deposit diff --git a/src/DepositSlot.java b/src/code/GUI/DepositSlot.java similarity index 98% rename from src/DepositSlot.java rename to src/code/GUI/DepositSlot.java index 64e02c2..bde0339 100644 --- a/src/DepositSlot.java +++ b/src/code/GUI/DepositSlot.java @@ -1,3 +1,4 @@ +package code.GUI; // DepositSlot.java // Represents the deposit slot of the ATM diff --git a/src/Keypad.java b/src/code/GUI/Keypad.java similarity index 98% rename from src/Keypad.java rename to src/code/GUI/Keypad.java index cd035c7..f0f716c 100644 --- a/src/Keypad.java +++ b/src/code/GUI/Keypad.java @@ -1,3 +1,4 @@ +package code.GUI; // Keypad.java // Represents the keypad of the ATM import java.util.Scanner; // program uses Scanner to obtain user input diff --git a/src/Screen.java b/src/code/GUI/Screen.java similarity index 98% rename from src/Screen.java rename to src/code/GUI/Screen.java index 44d3f30..d9ed691 100644 --- a/src/Screen.java +++ b/src/code/GUI/Screen.java @@ -1,3 +1,4 @@ +package code.GUI; // Screen.java // Represents the screen of the ATM diff --git a/src/Withdrawal.java b/src/code/GUI/Withdrawal.java similarity index 98% rename from src/Withdrawal.java rename to src/code/GUI/Withdrawal.java index 6e0af62..dc41b3b 100644 --- a/src/Withdrawal.java +++ b/src/code/GUI/Withdrawal.java @@ -1,6 +1,10 @@ +package code.GUI; // Withdrawal.java // Represents a withdrawal ATM transaction +import code.Database.BankDatabase; +import code.Database.Transaction; + public class Withdrawal extends Transaction { private int amount; // amount to withdraw From 27907926382bab5a0a2b4fcb7a23beee5c209535 Mon Sep 17 00:00:00 2001 From: s5027310 Date: Tue, 21 Nov 2023 17:22:46 +0100 Subject: [PATCH 2/5] sostituzione valuta double-euro (5027310) --- src/code/Buisness_logic/Account.java | 20 ++++++++++---------- src/code/Database/BankDatabase.java | 13 +++++++------ src/code/GUI/BalanceInquiry.java | 5 +++-- src/code/GUI/CashDispenser.java | 1 + src/code/GUI/Deposit.java | 13 ++++++++----- src/code/GUI/Screen.java | 5 +++-- src/code/GUI/Withdrawal.java | 24 +++++++++++++----------- 7 files changed, 45 insertions(+), 36 deletions(-) diff --git a/src/code/Buisness_logic/Account.java b/src/code/Buisness_logic/Account.java index 07d00f0..e6f965a 100644 --- a/src/code/Buisness_logic/Account.java +++ b/src/code/Buisness_logic/Account.java @@ -6,12 +6,12 @@ public class Account { private int accountNumber; // account number private int pin; // PIN for authentication - private double availableBalance; // funds available for withdrawal - private double totalBalance; // funds available + pending deposits + private Euro availableBalance; // funds available for withdrawal + private Euro totalBalance; // funds available + pending deposits // Account constructor initializes attributes public Account( int theAccountNumber, int thePIN, - double theAvailableBalance, double theTotalBalance ) + Euro theAvailableBalance, Euro theTotalBalance ) { accountNumber = theAccountNumber; pin = thePIN; @@ -29,28 +29,28 @@ public boolean validatePIN( int userPIN ) } // end method validatePIN // returns available balance - public double getAvailableBalance() + public Euro getAvailableBalance() { return availableBalance; } // end getAvailableBalance // returns the total balance - public double getTotalBalance() + public Euro getTotalBalance() { return totalBalance; } // end method getTotalBalance // credits an amount to the account - public void credit( double amount ) + public void credit( Euro amount ) { - totalBalance += amount; // add to total balance + totalBalance.somma(amount); // add to total balance } // end method credit // debits an amount from the account - public void debit( double amount ) + public void debit( Euro amount ) { - availableBalance -= amount; // subtract from available balance - totalBalance -= amount; // subtract from total balance + availableBalance.sottrai(amount); // subtract from available balance + totalBalance.sottrai(amount); // subtract from total balance } // end method debit // returns account number diff --git a/src/code/Database/BankDatabase.java b/src/code/Database/BankDatabase.java index d4d3509..8eedf03 100644 --- a/src/code/Database/BankDatabase.java +++ b/src/code/Database/BankDatabase.java @@ -3,6 +3,7 @@ // Represents the bank account information database import code.Buisness_logic.Account; +import code.Buisness_logic.Euro; public class BankDatabase { @@ -12,8 +13,8 @@ public class BankDatabase public BankDatabase() { accounts = new Account[ 2 ]; // just 2 accounts for testing - accounts[ 0 ] = new Account( 12345, 54321, 1000.0, 1200.0 ); - accounts[ 1 ] = new Account( 98765, 56789, 200.0, 200.0 ); + accounts[ 0 ] = new Account( 12345, 54321, new Euro(1000), new Euro(1200) ); + accounts[ 1 ] = new Account( 98765, 56789, new Euro(200), new Euro(200) ); } // end no-argument BankDatabase constructor // retrieve Account object containing specified account number @@ -45,25 +46,25 @@ public boolean authenticateUser( int userAccountNumber, int userPIN ) } // end method authenticateUser // return available balance of Account with specified account number - public double getAvailableBalance( int userAccountNumber ) + public Euro getAvailableBalance( int userAccountNumber ) { return getAccount( userAccountNumber ).getAvailableBalance(); } // end method getAvailableBalance // return total balance of Account with specified account number - public double getTotalBalance( int userAccountNumber ) + public Euro getTotalBalance( int userAccountNumber ) { return getAccount( userAccountNumber ).getTotalBalance(); } // end method getTotalBalance // credit an amount to Account with specified account number - public void credit( int userAccountNumber, double amount ) + public void credit( int userAccountNumber, Euro amount ) { getAccount( userAccountNumber ).credit( amount ); } // end method credit // debit an amount from of Account with specified account number - public void debit( int userAccountNumber, double amount ) + public void debit( int userAccountNumber, Euro amount ) { getAccount( userAccountNumber ).debit( amount ); } // end method debit diff --git a/src/code/GUI/BalanceInquiry.java b/src/code/GUI/BalanceInquiry.java index 2162c17..026e9ac 100644 --- a/src/code/GUI/BalanceInquiry.java +++ b/src/code/GUI/BalanceInquiry.java @@ -1,4 +1,5 @@ package code.GUI; +import code.Buisness_logic.Euro; // BalanceInquiry.java // Represents a balance inquiry ATM transaction @@ -22,11 +23,11 @@ public void execute() Screen screen = getScreen(); // get the available balance for the account involved - double availableBalance = + Euro availableBalance = bankDatabase.getAvailableBalance( getAccountNumber() ); // get the total balance for the account involved - double totalBalance = + Euro totalBalance = bankDatabase.getTotalBalance( getAccountNumber() ); // display the balance information on the screen diff --git a/src/code/GUI/CashDispenser.java b/src/code/GUI/CashDispenser.java index 4e95de8..d7dbef3 100644 --- a/src/code/GUI/CashDispenser.java +++ b/src/code/GUI/CashDispenser.java @@ -1,4 +1,5 @@ package code.GUI; + // CashDispenser.java // Represents the cash dispenser of the ATM diff --git a/src/code/GUI/Deposit.java b/src/code/GUI/Deposit.java index e68152e..352180c 100644 --- a/src/code/GUI/Deposit.java +++ b/src/code/GUI/Deposit.java @@ -1,4 +1,5 @@ package code.GUI; +import code.Buisness_logic.Euro; // Deposit.java // Represents a deposit ATM transaction @@ -7,10 +8,10 @@ public class Deposit extends Transaction { - private double amount; // amount to deposit + private Euro amount; // amount to deposit private Keypad keypad; // reference to keypad private DepositSlot depositSlot; // reference to deposit slot - private final static int CANCELED = 0; // constant for cancel option + private final static Euro CANCELED = new Euro(0); // constant for cancel option // Deposit constructor public Deposit( int userAccountNumber, Screen atmScreen, @@ -69,21 +70,23 @@ public void execute() } // end method execute // prompt user to enter a deposit amount in cents - private double promptForDepositAmount() + private Euro promptForDepositAmount() { Screen screen = getScreen(); // get reference to screen // display the prompt screen.displayMessage( "\nPlease enter a deposit amount in " + "CENTS (or 0 to cancel): " ); + int input = keypad.getInput(); // receive input of deposit amount + // check whether the user canceled or entered a valid amount - if ( input == CANCELED ) + if ( input == 0 ) return CANCELED; else { - return ( double ) input / 100; // return dollar amount + return new Euro((int)Math.floor(input/100), input%100); // return dollar amount } // end else } // end method promptForDepositAmount } // end class Deposit diff --git a/src/code/GUI/Screen.java b/src/code/GUI/Screen.java index d9ed691..65f0df4 100644 --- a/src/code/GUI/Screen.java +++ b/src/code/GUI/Screen.java @@ -1,4 +1,5 @@ package code.GUI; +import code.Buisness_logic.Euro; // Screen.java // Represents the screen of the ATM @@ -17,9 +18,9 @@ public void displayMessageLine( String message ) } // end method displayMessageLine // display a dollar amount - public void displayDollarAmount( double amount ) + public void displayDollarAmount( Euro amount ) { - System.out.printf( "$%,.2f", amount ); + System.out.printf( amount.stampa() ); } // end method displayDollarAmount } // end class Screen diff --git a/src/code/GUI/Withdrawal.java b/src/code/GUI/Withdrawal.java index dc41b3b..70c2c1b 100644 --- a/src/code/GUI/Withdrawal.java +++ b/src/code/GUI/Withdrawal.java @@ -1,4 +1,5 @@ package code.GUI; +import code.Buisness_logic.Euro; // Withdrawal.java // Represents a withdrawal ATM transaction @@ -7,12 +8,13 @@ public class Withdrawal extends Transaction { - private int amount; // amount to withdraw + private Euro amount; // amount to withdraw private Keypad keypad; // reference to keypad private CashDispenser cashDispenser; // reference to cash dispenser + private final static Euro EMPTY = new Euro(0); // constant for cancel option // constant corresponding to menu option to cancel - private final static int CANCELED = 6; + private final static Euro CANCELED = new Euro(6); // Withdrawal constructor public Withdrawal( int userAccountNumber, Screen atmScreen, @@ -31,7 +33,7 @@ public Withdrawal( int userAccountNumber, Screen atmScreen, public void execute() { boolean cashDispensed = false; // cash was not dispensed yet - double availableBalance; // amount available for withdrawal + Euro availableBalance; // amount available for withdrawal // get references to bank database and screen BankDatabase bankDatabase = getBankDatabase(); @@ -51,15 +53,15 @@ public void execute() bankDatabase.getAvailableBalance( getAccountNumber() ); // check whether the user has enough money in the account - if ( amount <= availableBalance ) + if ( amount.minoreDi(availableBalance) ) { // check whether the cash dispenser has enough money - if ( cashDispenser.isSufficientCashAvailable( amount ) ) + if ( cashDispenser.isSufficientCashAvailable((int)amount.getValore() ) ) { // update the account involved to reflect withdrawal bankDatabase.debit( getAccountNumber(), amount ); - cashDispenser.dispenseCash( amount ); // dispense cash + cashDispenser.dispenseCash((int)amount.getValore() ); //get valore ritorna long, ma il massimo ritirabile è 500, quindi la conversione è sicura cashDispensed = true; // cash was dispensed // instruct user to take cash @@ -89,9 +91,9 @@ public void execute() // display a menu of withdrawal amounts and the option to cancel; // return the chosen amount or 0 if the user chooses to cancel - private int displayMenuOfAmounts() + private Euro displayMenuOfAmounts() { - int userChoice = 0; // local variable to store return value + Euro userChoice = EMPTY ; // local variable to store return value Screen screen = getScreen(); // get screen reference @@ -99,7 +101,7 @@ private int displayMenuOfAmounts() int amounts[] = { 0, 20, 40, 60, 100, 200 }; // loop while no valid choice has been made - while ( userChoice == 0 ) + while ( userChoice == EMPTY ) { // display the menu screen.displayMessageLine( "\nWithdrawal Menu:" ); @@ -121,9 +123,9 @@ private int displayMenuOfAmounts() case 3: // corresponding amount from amounts array case 4: case 5: - userChoice = amounts[ input ]; // save user's choice + userChoice = new Euro (amounts[ input ]); // save user's choice break; - case CANCELED: // the user chose to cancel + case 6: // the user chose to cancel userChoice = CANCELED; // save user's choice break; default: // the user did not enter a value from 1-6 From 5d835ab01ff47fd36aa069b67c9ba875a9be90ab Mon Sep 17 00:00:00 2001 From: AndreaParisiUnige Date: Thu, 23 Nov 2023 16:47:03 +0100 Subject: [PATCH 3/5] Correzioni su Withdrawal e Deposit per gestione tipo Euro --- src/code/GUI/Deposit.java | 8 ++++---- src/code/GUI/Withdrawal.java | 26 +++++++++++++------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/code/GUI/Deposit.java b/src/code/GUI/Deposit.java index 352180c..2d0f2b0 100644 --- a/src/code/GUI/Deposit.java +++ b/src/code/GUI/Deposit.java @@ -11,7 +11,7 @@ public class Deposit extends Transaction private Euro amount; // amount to deposit private Keypad keypad; // reference to keypad private DepositSlot depositSlot; // reference to deposit slot - private final static Euro CANCELED = new Euro(0); // constant for cancel option + private final static int CANCELED = 0; // constant for cancel option // Deposit constructor public Deposit( int userAccountNumber, Screen atmScreen, @@ -35,7 +35,7 @@ public void execute() amount = promptForDepositAmount(); // get deposit amount from user // check whether user entered a deposit amount or canceled - if ( amount != CANCELED ) + if ( amount.getValore() != CANCELED ) { // request deposit envelope containing specified amount screen.displayMessage( @@ -83,10 +83,10 @@ private Euro promptForDepositAmount() // check whether the user canceled or entered a valid amount if ( input == 0 ) - return CANCELED; + return new Euro(0); //CANCELED else { - return new Euro((int)Math.floor(input/100), input%100); // return dollar amount + return new Euro((long)Math.floor(input/100), input%100); // return dollar amount } // end else } // end method promptForDepositAmount } // end class Deposit diff --git a/src/code/GUI/Withdrawal.java b/src/code/GUI/Withdrawal.java index 70c2c1b..2501227 100644 --- a/src/code/GUI/Withdrawal.java +++ b/src/code/GUI/Withdrawal.java @@ -8,13 +8,12 @@ public class Withdrawal extends Transaction { - private Euro amount; // amount to withdraw + private int amount; // amount to withdraw private Keypad keypad; // reference to keypad private CashDispenser cashDispenser; // reference to cash dispenser - private final static Euro EMPTY = new Euro(0); // constant for cancel option // constant corresponding to menu option to cancel - private final static Euro CANCELED = new Euro(6); + private final static int CANCELED = 6; // Withdrawal constructor public Withdrawal( int userAccountNumber, Screen atmScreen, @@ -51,17 +50,18 @@ public void execute() // get available balance of account involved availableBalance = bankDatabase.getAvailableBalance( getAccountNumber() ); - + + Euro euroAmount = new Euro(amount); // check whether the user has enough money in the account - if ( amount.minoreDi(availableBalance) ) + if ( euroAmount.minoreDi(availableBalance) ) { // check whether the cash dispenser has enough money - if ( cashDispenser.isSufficientCashAvailable((int)amount.getValore() ) ) + if ( cashDispenser.isSufficientCashAvailable( amount ) ) { // update the account involved to reflect withdrawal - bankDatabase.debit( getAccountNumber(), amount ); + bankDatabase.debit( getAccountNumber(), euroAmount ); - cashDispenser.dispenseCash((int)amount.getValore() ); //get valore ritorna long, ma il massimo ritirabile è 500, quindi la conversione è sicura + cashDispenser.dispenseCash( amount ); // dispense cash cashDispensed = true; // cash was dispensed // instruct user to take cash @@ -91,9 +91,9 @@ public void execute() // display a menu of withdrawal amounts and the option to cancel; // return the chosen amount or 0 if the user chooses to cancel - private Euro displayMenuOfAmounts() + private int displayMenuOfAmounts() { - Euro userChoice = EMPTY ; // local variable to store return value + int userChoice = 0; // local variable to store return value Screen screen = getScreen(); // get screen reference @@ -101,7 +101,7 @@ private Euro displayMenuOfAmounts() int amounts[] = { 0, 20, 40, 60, 100, 200 }; // loop while no valid choice has been made - while ( userChoice == EMPTY ) + while ( userChoice == 0 ) { // display the menu screen.displayMessageLine( "\nWithdrawal Menu:" ); @@ -123,9 +123,9 @@ private Euro displayMenuOfAmounts() case 3: // corresponding amount from amounts array case 4: case 5: - userChoice = new Euro (amounts[ input ]); // save user's choice + userChoice = amounts[ input ]; // save user's choice break; - case 6: // the user chose to cancel + case CANCELED: // the user chose to cancel userChoice = CANCELED; // save user's choice break; default: // the user did not enter a value from 1-6 From f6e06aa0b477e86338284b52982775e2acfaf92b Mon Sep 17 00:00:00 2001 From: AndreaParisiUnige Date: Sat, 25 Nov 2023 18:53:13 +0100 Subject: [PATCH 4/5] Commento in promptForDepositAmount (5293937) --- src/code/GUI/Deposit.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/code/GUI/Deposit.java b/src/code/GUI/Deposit.java index 2d0f2b0..8aab3ce 100644 --- a/src/code/GUI/Deposit.java +++ b/src/code/GUI/Deposit.java @@ -86,7 +86,12 @@ private Euro promptForDepositAmount() return new Euro(0); //CANCELED else { - return new Euro((long)Math.floor(input/100), input%100); // return dollar amount + return new Euro((long)Math.floor(input/100), input%100); + /* abbiamo fatto in modo che si possa costruire un oggetto + euro partendo da un long, abbiamo fatto il cast a long poichè + Math.floor resituisce un double ma siccome ci interessa la + parte intera non dovrebbe essere un problema */ + } // end else } // end method promptForDepositAmount } // end class Deposit From 38f78932dfce6d15da9bb4ec55a80d7481ce9e6b Mon Sep 17 00:00:00 2001 From: AndreaParisiUnige <146130874+AndreaParisiUnige@users.noreply.github.com> Date: Sat, 25 Nov 2023 19:18:32 +0100 Subject: [PATCH 5/5] Aggiunta file componenti --- componenti.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 componenti.txt diff --git a/componenti.txt b/componenti.txt new file mode 100644 index 0000000..50a7c45 --- /dev/null +++ b/componenti.txt @@ -0,0 +1,3 @@ +Andrea Parisi 5202353 +Alessandro Borracino 5027310 +Giacomo Carena 5293937 \ No newline at end of file