From 608c59d3e32414621e2338855fea41e7a30d6d75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Heredero?= Date: Thu, 5 May 2022 16:12:28 +0200 Subject: [PATCH] work on class 05/05 --- .vscode/launch.json | 14 +++++++ bill.txt | 17 ++++++++ bin/BillGUI/ManagerGui.class | Bin 0 -> 273 bytes bin/GUI/ButtonListener.class | Bin 1126 -> 1126 bytes bin/GUI/GUI1.class | Bin 1337 -> 1320 bytes bin/GUI/GUI2.class | Bin 363 -> 1497 bytes bin/GUI/Listener.class | Bin 0 -> 1136 bytes bin/bank/BankAccount.class | Bin 1479 -> 1479 bytes bin/bank/Checking.class | Bin 1116 -> 1116 bytes bin/bank/Savings.class | Bin 1044 -> 1044 bytes src/BillGUI/ManagerGui.java | 10 +++++ src/GUI/GUI1.java | 5 +-- src/GUI/GUI2.java | 76 +++++++++++++++++++++++++++++++++-- src/bank/BankAccount.java | 32 +++++++++++++-- src/bank/Checking.java | 23 +++++++++++ src/bank/Savings.java | 16 ++++++++ 16 files changed, 183 insertions(+), 10 deletions(-) create mode 100644 bill.txt create mode 100644 bin/BillGUI/ManagerGui.class create mode 100644 bin/GUI/Listener.class create mode 100644 src/BillGUI/ManagerGui.java diff --git a/.vscode/launch.json b/.vscode/launch.json index 991d31d..04c4a81 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -1,5 +1,19 @@ { "configurations": [ + { + "type": "java", + "name": "Launch GUI2", + "request": "launch", + "mainClass": "GUI.GUI2", + "projectName": "Lab15_OOP_90898795" + }, + { + "type": "java", + "name": "Launch GarageManager", + "request": "launch", + "mainClass": "BillGUI.GarageManager", + "projectName": "Lab15_OOP_90898795" + }, { "type": "java", "name": "Launch GUI1", diff --git a/bill.txt b/bill.txt new file mode 100644 index 0000000..5f2debd --- /dev/null +++ b/bill.txt @@ -0,0 +1,17 @@ +************************* +* Super Auto 20000 bill **** +******************************* + +- Tire replacement 50 +- Tire replacement 50 +- Tire replacement 50 +- Tire replacement 50 +- Battery replacement 320 +- Brake revision 400 +- Oil level control 20 + +---------------------------------- + Bill total 940 +---------------------------------- + +Payment in 30 days. Thank you ! \ No newline at end of file diff --git a/bin/BillGUI/ManagerGui.class b/bin/BillGUI/ManagerGui.class new file mode 100644 index 0000000000000000000000000000000000000000..295fc329e12d50fb426a43762dccc68e402bae55 GIT binary patch literal 273 zcmZWjF>b;@5S%qO28YB52(_-~l`;${s>W zK{K;6tI^E$_k02Hj;arbQ0sD%^rwSpq*Argrk}G9SNw0aSI203;B*xYdq!W;3}y_v43#o)$ZGuf2I F5C9TY2=o8| delta 51 zcmaFH@r+|bH#4Um0}F#b11E#QXcfCk7g29`1SR_t z#yh>(Mw@tTd;)KL5O37knyA@5GvAr{X6DSC^HG1R>tBC<`V35wJ=Wi~=>({)A)?S$ zb2^GFC1mq{$dh@$>)=%T%6?;DIV z=6+M%y=R#SF|LUGM<_T}zK|2rIVRl}EvnADb6Weo3yMI}wsjIr8|bvwa7j$N)_#aN z$*{DQiZ2{Ej$KISi%w25=*)82r(RLCMbmzX7xCg@zVINvoZPpb6)EQBf2UobQBKf6P_#~%W+HOU%?!%(8KF%k*1b!E2&VD7iuK&TIE&#bA(@de*SX1xCC@HQpRGiD7wfRlFEy zJU~Lx_Ahnb-FA0Pl3bL3W>+(r6-ChgpO(rmF&W^pB7B0`sW|1Gk|bZ@s^`<9>Y5kV zBK=be--7EJ(uf--1`(Z`a9j(8m#0dP719a~)L&yzK77u$#;TmRs*HX? z&_sE#BR5wubxU9^svo$|+f{8erz8rF(exwBy<8di=^lsG3PK$rtR?NV=t ztWE~xQj8E`j9%$%A8Go@$rV_W(H0rvA;XkpxX&2nxlFdMZIULjFSsX)knAPyvnmSH bGPpG!i1Hj!)&=>*A0W>Le&Guetx@~~HU542 diff --git a/bin/GUI/GUI2.class b/bin/GUI/GUI2.class index 2e298c9859b4a748b9b493b55f5f6679e7bde8c2..02a0620353f760a4af12c26a88357f0d179c3564 100644 GIT binary patch literal 1497 zcmZuxZBr9h7(JJ4SXkC5sKHdRTA^$bLd0sRgj!2%Bs5UkXf)a{7qZ56l3i!Bh;6^L zKdE1mnP#S+JN~GS=k5Y#87A46`@EdzdCon1Km7mCzW`S8tBx^&iN{Z?MP7GwXaX~D z$s_g{DS4Ivy#JJ=JBPDg(GTjI_{R?X>=V%1>@4^+-~0+lG|L}epQltLCyJYnrqwrFCqp+^1Q#0JU&)3VhnzoruH z>7ve$j!jA%mV%zCC zp`b5txlpa3VHlCf@W`$au_uB!JNSmfp|e z-cf25K!+hw@lzbLFV;?ljUH1-P^0c0`1^LnQQzsLIwh8sesGh6CwPbmUP+AeK88u? zn4o2nt9yJZpFV^b!1y~1Nbznk5J)lQJb$1d!Z2LGG*@bUE`kt?1lDQ!D>uMQZW{mb z-^az=^w{(8Z8q2Ev_o8P=CuKCZ0DEyxHUw!nYhpzAiq;c^iddMC0c*ArVVkoIrH@Z z->fBvC^a)$CRrHZ+qLmRX1tGw`9dF$p5-%I^hl~lj*HDt%~!%EFG1t6lR_F-FpD|f z7kShy;VO^RYgngclLtc`H=uZG;}*J@M}P(V!N@;hg@bQK!=Z+44mpPwcJLENU&IUS n;%CydN?rXzoCNXi;|ZR!ZXL^L;2Eir#D9(^i4@FG{J;DNj&oZ1 literal 363 zcmZutO-sW-5Pg%TNfWEpR=j(w3I@D*sCW?+A?Tsni>FOo;+Av+G4+4-BzW)#_@l(P zQBlOhyxIA9^Jez#{pA(FF}6c^g5JgLWkNd&;R`nB>PaP~vPE*8&2`=gf)is+b1LYJ z_hthBth(1RI*9t{A`lExWA)W?k?HzIWu+Dj(<)cxOx4E4UrE1tFpq*b{nnds)hW#Lf_qg tMsL-YW1=gAgf(LSvw?n{QG^W)m~rF-n(LFl#NZc^--oTXaY*zq`T(|wKFI(8 diff --git a/bin/GUI/Listener.class b/bin/GUI/Listener.class new file mode 100644 index 0000000000000000000000000000000000000000..feb560b47998cf0768fedec1d69ab0e28a26338d GIT binary patch literal 1136 zcmZWoYflqF6g@*L3w5PPc@#ZjrxbLQA5F zKfoVlJTqIR8=CCQo%=lZ+}q!Oe*6Nkg4YJR1kAUe%XY;LBk9Y)Kw6;x#5r?p&+(7! zkF^td5EJw0 zFzHfpYSPojkj9~;anExPr3&r#8((WO5D;ZPR$bqX)&+J7N%zijNlRQMscR=MRt3`A z^+TCK3ON&53=(RgSnY+tu!&pfQ_`pj13gL_GtrBTk|s>tgej1%xW4?L5$-!RPYMiF z>IaTjbpltt+sbrw?1ln;l}^^#oEb(=Bx6Dk1*Vf-b<+JtQC})nGq{h31|A6H5`4!k znRtYPK+lnks*cwn9JW(7UyhFNipZ&B-oyfIa_pR*N}p&Z3gx2a zEnbR5R7piFnpnaUmW%4Kks~f#525ceRt!8NISI^qG$x+og@6&tXkVU3T!ff}&Z4^S z64nf?avX^q9fLQqjt!z=rgrmbcEA}6@-Ug$fa}Z(WcKQf;6U!UYKpxa)Y5{ggei_Y z#qS2v{QqzhctY)gzPSbZ=C1JW;+I7~y>C-$@U3F<)+Gk4R1-tiY!f5aT$8H#CdR+( zkUKob(9Ls=?#oQQ&SV?N;T1-)iMzB|aUx6-j{4;_5TPXnMHSAgmDEu0VY&^W&bPAJ zmUV&g7G@NP3*>*I_~jC_6o*=vYvFMVPx%;$6)&%V4d}vUrryO2-f>0VYe2(s+W&xT Og56|Mfi0Hn!uDTApZ&!E literal 0 HcmV?d00001 diff --git a/bin/bank/BankAccount.class b/bin/bank/BankAccount.class index 97add3433d512c55b6963ad06b5094104cebffef..afd2757f68823a43ca213702d2e1d9a37a38ea85 100644 GIT binary patch delta 75 zcmX@keVlv4S!PDI$>*4D82Kl2vjhlAFt9O5GVn4;G4L_SFi0@SPR?OT<5gqeWKd@i eV9*4LYfZk-lEiAvAjV)a*^M=Y(Pr{$Rv7>`2M!$o delta 75 zcmX@keVlv4S!PD&$>*4D7&#_$vjhloGq5r6Fz^B)9|J#w1cSij9F{a*AqGwcVFm#P cQ3fdnvB~#Yl30N>gY;xK))Ypi$*Wmq030X{HUIzs diff --git a/bin/bank/Checking.class b/bin/bank/Checking.class index f7457786ca19443a4847348f2ad48623c677d719..f2f805926a0a0c4ab7b76f1f31c62afc6f1dd16b 100644 GIT binary patch delta 111 zcmcb^aff5W1}0Mh1{MZE1`Y-x27U%%1_1_925|;4200)p&mhU5#vsL@%OK65#~{mK z3>38hirO(KOn%DLB&g27#-PE#%b>}?$Dj?=t24QR*`LvP@(Jb$UTdJ34bUt*pnChs Hx-9wtCf5$; delta 111 zcmcb^aff5W1}0NB1{MZ(1`Z(PXW(QIVBlsDXW(IwW8h_w2a2cxMRXYi8T1&08H^c3 z7%Uh>8SEIuCO>6r5|m(IV~_-@lVadwkO9iePOf0~XOy3Of;oa$1t_KpRI3g&MPsrq Gi#`DC6%C&N diff --git a/bin/bank/Savings.class b/bin/bank/Savings.class index 2f9c7b368aefbfbf3b0753e0e78055ba0afc85e8..03048f22d952dac9869b6a1501ed62ffb7cbf9cb 100644 GIT binary patch delta 75 zcmbQjF@dg8&0BgBSxJgDj9I#~{d{${@s`!ywF{%OJ{N c1e7sn5NEJukeD36+{!A=z|J5u`4+Pk01prd6aWAK diff --git a/src/BillGUI/ManagerGui.java b/src/BillGUI/ManagerGui.java new file mode 100644 index 0000000..f3bfcc2 --- /dev/null +++ b/src/BillGUI/ManagerGui.java @@ -0,0 +1,10 @@ +package BillGUI; + +import javax.swing.JFrame; + +/** + * + */ +public class ManagerGui extends JFrame{ + +} diff --git a/src/GUI/GUI1.java b/src/GUI/GUI1.java index a484750..ddf099f 100644 --- a/src/GUI/GUI1.java +++ b/src/GUI/GUI1.java @@ -2,7 +2,6 @@ package GUI; import javax.swing.*; -import java.awt.AWTEvent; import java.awt.Color; import java.awt.FlowLayout; import java.awt.event.ActionEvent; @@ -10,9 +9,7 @@ import java.awt.event.ActionListener; public class GUI1 extends JFrame { public static void main(String[] args) { - GUI1 f1 = new GUI1(); - - + new GUI1(); } GUI1(){ diff --git a/src/GUI/GUI2.java b/src/GUI/GUI2.java index 818ff5f..6dba5c8 100644 --- a/src/GUI/GUI2.java +++ b/src/GUI/GUI2.java @@ -1,10 +1,80 @@ package GUI; -public class GUI2 { +import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.Container; + +/** + * + */ +public class GUI2 extends JFrame{ + int number; public static void main(String[] args) { - + new GUI2(); + } + + /** + * + */ + GUI2(){ + setSize(200,200); + setLocation(600,200); + Container c = this.getContentPane(); + BoxLayout fl = new BoxLayout(c, BoxLayout.Y_AXIS); + c.setLayout(fl); + + JSlider js1 = new JSlider(0, 100); + js1.setValue(0); + JProgressBar jp1 = new JProgressBar(0, 100); + JLabel jl1 = new JLabel("waiting"); + + Listener l = new Listener(jp1, jl1, js1); + js1.addChangeListener(l); + + c.add(js1); + c.add(jp1); + c.add(jl1); + + this.setVisible(true); } - } + +/** + * + */ +class Listener implements ChangeListener { + JProgressBar jp1; + JLabel jl1; + JSlider js1; + + int number = 0; + + /** + * + * @param jp1 + * @param jl1 + * @param js1 + */ + Listener(JProgressBar jp1, JLabel jl1, JSlider js1){ + this.jp1 = jp1; + this.jl1 = jl1; + this.js1 = js1; + } + + /** + * + * @param e + */ + @Override + public void stateChanged(ChangeEvent e) { + number = js1.getValue(); + jl1.setText("" + number); + jp1.setValue(number); + + } + +} + diff --git a/src/bank/BankAccount.java b/src/bank/BankAccount.java index c914dc8..0b8d81f 100644 --- a/src/bank/BankAccount.java +++ b/src/bank/BankAccount.java @@ -1,12 +1,25 @@ package bank; +/** + * Create a bank account with a balance and a owner + */ public abstract class BankAccount { protected double balance; protected String owner; + /** + * Get balance of the account + * @return the balance of the account + */ public double getBalance() { return balance; } + + /** + * Deposit an amount on your account + * Check the amount for accept only positive amount. + * @param amount + */ public void deposit(double amount){ if(amount<0){ error("cannot deposit this amount !"); @@ -14,6 +27,13 @@ public abstract class BankAccount { } balance += amount; } + + /** + * Withdraw an amount on your account + * Check the amount for be sure you have this money + * @param amount The amount you want to withdraw + * @return true : if the withdraw has been done + */ public boolean withdraw(double amount){ if(balance0){ error("Min balance can't be positive"); @@ -27,10 +42,18 @@ public class Checking extends BankAccount{ } this.minBalance = minBalance; } + + /** + * + * @return + */ public double getMinBalance() { return minBalance; } + /** + * + */ @Override public boolean withdraw(double amount){ if((balance-minBalance)