Compare commits
	
		
			9 Commits
		
	
	
		
			debug-logo
			...
			Submit
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 2f45a5a342 | |||
|  | 9d4c6ecc7d | ||
|  | 3a01bb88d4 | ||
|  | 354ea04dff | ||
|  | 91320444a5 | ||
|  | e245dcba52 | ||
|  | 21070c07be | ||
|  | 095fa60a3d | ||
|  | 5fb795df73 | 
							
								
								
									
										38
									
								
								.vscode/launch.json
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										38
									
								
								.vscode/launch.json
									
									
									
									
										vendored
									
									
								
							| @@ -1,5 +1,35 @@ | ||||
| { | ||||
|     "configurations": [ | ||||
|         { | ||||
|             "type": "java", | ||||
|             "name": "Launch CompleteBankController", | ||||
|             "request": "launch", | ||||
|             "mainClass": "bank.CompleteBankController", | ||||
|             "projectName": "Lab15_OOP_90898795", | ||||
|             "vmArgs": "-enableassertions" | ||||
|         }, | ||||
|         { | ||||
|             "type": "java", | ||||
|             "name": "Launch BankController", | ||||
|             "request": "launch", | ||||
|             "mainClass": "bank.CompleteBankController", | ||||
|             "projectName": "Lab15_OOP_fc166bd2", | ||||
|             "vmArgs": "-enableassertions" | ||||
|         }, | ||||
|         { | ||||
|             "type": "java", | ||||
|             "name": "Launch GUI2", | ||||
|             "request": "launch", | ||||
|             "mainClass": "GUI.GUI2", | ||||
|             "projectName": "Lab15_OOP_79fdc875" | ||||
|         }, | ||||
|         { | ||||
|             "type": "java", | ||||
|             "name": "Launch GUI1", | ||||
|             "request": "launch", | ||||
|             "mainClass": "GUI.GUI1", | ||||
|             "projectName": "Lab15_OOP_79fdc875" | ||||
|         }, | ||||
|         { | ||||
|             "type": "java", | ||||
|             "name": "Launch HesSoGarage", | ||||
| @@ -35,14 +65,6 @@ | ||||
|             "mainClass": "GUI.GUI1", | ||||
|             "projectName": "Lab15_OOP_90898795", | ||||
|             "liveshare.allowGuestDebugControl": true | ||||
|         }, | ||||
|         { | ||||
|             "type": "java", | ||||
|             "name": "Launch BankController", | ||||
|             "request": "launch", | ||||
|             "mainClass": "bank.BankController", | ||||
|             "projectName": "Lab15_OOP_90898795", | ||||
|             "vmArgs": "-enableassertions" | ||||
|         } | ||||
|     ] | ||||
| } | ||||
|   | ||||
							
								
								
									
										1
									
								
								.vscode/settings.json
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.vscode/settings.json
									
									
									
									
										vendored
									
									
								
							| @@ -7,6 +7,7 @@ | ||||
|     "liveshare.shareExternalFiles": false, | ||||
|     "liveshare.allowGuestDebugControl": true, | ||||
|     "cSpell.words": [ | ||||
|         "Jframe", | ||||
|         "Jlogo", | ||||
|         "Jname" | ||||
|     ] | ||||
|   | ||||
							
								
								
									
										
											BIN
										
									
								
								bin/BillGUI/BillGui$1$1.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								bin/BillGUI/BillGui$1$1.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								bin/BillGUI/BillGui$1.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								bin/BillGUI/BillGui$1.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								bin/BillGUI/BillGui.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								bin/BillGUI/BillGui.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								bin/BillGUI/ButtonListenerBill.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								bin/BillGUI/ButtonListenerBill.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								bin/BillGUI/ButtonListenerManager.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								bin/BillGUI/ButtonListenerManager.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								bin/BillGUI/GarageManager.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								bin/BillGUI/GarageManager.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								bin/BillGUI/HesSoGarage.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								bin/BillGUI/HesSoGarage.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								bin/BillGUI/ManagerGui$1.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								bin/BillGUI/ManagerGui$1.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								bin/BillGUI/ManagerGui$2.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								bin/BillGUI/ManagerGui$2.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								bin/BillGUI/ManagerGui.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								bin/BillGUI/ManagerGui.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								bin/BillGUI/Row.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								bin/BillGUI/Row.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								bin/GUI/ButtonListener.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								bin/GUI/ButtonListener.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								bin/GUI/GUI1.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								bin/GUI/GUI1.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								bin/GUI/GUI2.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								bin/GUI/GUI2.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								bin/GUI/Listener.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								bin/GUI/Listener.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								bin/bank/BankAccount.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								bin/bank/BankAccount.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								bin/bank/BankController.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								bin/bank/BankController.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								bin/bank/Checking.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								bin/bank/Checking.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								bin/bank/Savings.class
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								bin/bank/Savings.class
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| @@ -6,10 +6,17 @@ import javax.swing.*; | ||||
| import java.awt.print.*; | ||||
| import java.awt.image.BufferedImage; | ||||
|  | ||||
| /** | ||||
|  * generate the bill in a window | ||||
|  */ | ||||
| public class BillGui extends JFrame{ | ||||
|     String bill; | ||||
|     JPanel jP; | ||||
|  | ||||
|     /** | ||||
|      * initialize the bill in a window | ||||
|      * @param bill string who contains the bill | ||||
|      */ | ||||
|     BillGui(String bill){ | ||||
|         this.bill = bill; | ||||
|  | ||||
| @@ -20,23 +27,26 @@ public class BillGui extends JFrame{ | ||||
|         FlowLayout fl = new FlowLayout(); | ||||
| 		this.setLayout(fl); | ||||
|  | ||||
|         //Create the label who contain the label with the bill | ||||
|         jP = new JPanel(); | ||||
|  | ||||
|         JLabel jBill = new JLabel(bill); | ||||
|         jP.add(jBill); | ||||
|          | ||||
|         this.add(jP); | ||||
|  | ||||
|         //Create the button for print the bill | ||||
|         JButton buttonPrint = new JButton("Print"); | ||||
|         buttonPrint.addActionListener( | ||||
|         buttonPrint.addActionListener(new ButtonListenerBill() { | ||||
|          | ||||
|             new ButtonListenerBill(this) { | ||||
|             @Override | ||||
|             public void actionPerformed(ActionEvent e){ | ||||
|  | ||||
|                 // Create a new printer Job | ||||
|                 PrinterJob pj = PrinterJob.getPrinterJob(); | ||||
|                 pj.setJobName("Bill"); | ||||
|  | ||||
|                 // Create a printable element from a JPanel. This method is just a copy, it resize but isn't perfect. | ||||
|                 // It's just a first test. Should be improved | ||||
|                 // TODO : improve this method | ||||
|                 Printable printable = new Printable() {     | ||||
|                     public int print(Graphics pg, PageFormat pf, int pageNum){ | ||||
|                         if (pageNum > 0) return Printable.NO_SUCH_PAGE; | ||||
| @@ -54,40 +64,39 @@ public class BillGui extends JFrame{ | ||||
|                     } | ||||
|                 }; | ||||
|  | ||||
|                 // Create and set a A4 paper | ||||
|                 Paper paper = new Paper(); | ||||
|                 paper.setImageableArea(0, 0,2480,3508); | ||||
|                 paper.setSize(2480,3508); | ||||
|              | ||||
|                 PageFormat format = new PageFormat(); | ||||
|                 format.setPaper(paper); | ||||
|                 format.setOrientation(PageFormat.PORTRAIT); | ||||
|  | ||||
|                 // Set all settings about the printing function | ||||
|                 pj.setPrintable (printable, format); | ||||
|  | ||||
|                 // Launch the printer dialog for printing. | ||||
|                 if (pj.printDialog() == false) return; | ||||
|  | ||||
|                 try { | ||||
|                     pj.print(); | ||||
|                 } catch (PrinterException ex) {} | ||||
|             } | ||||
|         }); | ||||
|  | ||||
|  | ||||
|         this.add(buttonPrint); | ||||
|  | ||||
|          | ||||
|     } | ||||
|  | ||||
| } | ||||
|  | ||||
| /** | ||||
|  *  | ||||
|  * listener to detect the button to print the bill | ||||
|  */ | ||||
| class ButtonListenerBill implements ActionListener { | ||||
|     JFrame Jf; | ||||
|  | ||||
|     ButtonListenerBill(JFrame Jf){ | ||||
|         this.Jf = Jf; | ||||
|     } | ||||
|      | ||||
|     @Override | ||||
|     public void actionPerformed(ActionEvent e){  }; | ||||
|     public void actionPerformed(ActionEvent e){}; | ||||
| } | ||||
|  | ||||
|  | ||||
|   | ||||
| @@ -2,10 +2,12 @@ package BillGUI; | ||||
|  | ||||
| public class HesSoGarage { | ||||
|     public static void main(String[] args) { | ||||
|         //Create a new garage | ||||
|         GarageManager garageManager = new GarageManager(); | ||||
|         String name = "<html><body><i>Garage manager</i><br>Prestations</body></html>"; | ||||
|         String logoFilePath = "src/logo_garage.png"; //TODO redimensionnement automatique | ||||
|         new ManagerGui(name, logoFilePath, garageManager.getServices(), garageManager); //TODO affichage sans redimensionnement | ||||
|         String logoFilePath = "src/logo_garage.png"; | ||||
|         //Create a new HMI for calculate and print the bill | ||||
|         new ManagerGui(name, logoFilePath, garageManager.getServices(), garageManager);  | ||||
|     } | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -6,7 +6,7 @@ import java.util.Vector; | ||||
| import javax.swing.*; | ||||
|  | ||||
| /** | ||||
|  *  | ||||
|  * HMI for calculate the bill | ||||
|  */ | ||||
| public class ManagerGui extends JFrame { | ||||
|     GridLayout grid; | ||||
| @@ -15,7 +15,7 @@ public class ManagerGui extends JFrame { | ||||
|     ImageIcon logo; | ||||
|     String buttonNameQuit = "Quit"; | ||||
|     String buttonNameBill = "Show bill"; | ||||
|     double ratio = 207.0/163.0; | ||||
|     double ratio = 207.0 / 163.0; | ||||
|      | ||||
|  | ||||
|     Vector<Row> prestations = new Vector<>(); | ||||
| @@ -23,13 +23,17 @@ public class ManagerGui extends JFrame { | ||||
|      | ||||
|  | ||||
|     /** | ||||
|      *  | ||||
|      * initialize the window | ||||
|      * @param name name of the garage | ||||
|      * @param logoFilePath file of the garage's logo | ||||
|      * @param prestationsName array with the name of the prestations | ||||
|      * @param garageManager a new garage application | ||||
|      */ | ||||
|     public ManagerGui(String name, String logoFilePath, String[] prestationsName, GarageManager garageManager){ | ||||
|         //set up the window with the layout | ||||
|         this.setSize(400,600); | ||||
|         this.setLocation(600,200); | ||||
|         this.setVisible(true); | ||||
|  | ||||
|         grid = new GridLayout(prestationsName.length + 2,2); | ||||
|         this.setLayout(grid); | ||||
|  | ||||
| @@ -44,7 +48,6 @@ public class ManagerGui extends JFrame { | ||||
|         Jlogo = resize(Jname, logoFilePath); | ||||
|         this.add(Jlogo); | ||||
|  | ||||
|  | ||||
|         //Create rows for prestations | ||||
|         for(String s : prestationsName){ | ||||
|             prestations.add(new Row(s)); | ||||
| @@ -59,7 +62,7 @@ public class ManagerGui extends JFrame { | ||||
|         JButton buttonBill = new JButton(buttonNameBill); | ||||
|         buttonBill.addActionListener(new ButtonListenerManager(valuePrestations, prestations, garageManager){ | ||||
|             /** | ||||
|              *  | ||||
|              * add the number of prestations when it is used | ||||
|              */ | ||||
|             @Override | ||||
|             public void actionPerformed(ActionEvent e){ | ||||
| @@ -71,7 +74,7 @@ public class ManagerGui extends JFrame { | ||||
|                     } | ||||
|                     System.out.println(value); | ||||
|                 } | ||||
|                  | ||||
|                 //Create the bill | ||||
|                 new BillGui(garageManager.generateHTMLBill(valuePrestations)); | ||||
|             }; | ||||
|         }); | ||||
| @@ -79,7 +82,7 @@ public class ManagerGui extends JFrame { | ||||
|         JButton buttonQuit = new JButton(buttonNameQuit); | ||||
|         buttonQuit.addActionListener(new ButtonListenerManager(this){ | ||||
|             /** | ||||
|              *  | ||||
|              * quit the window | ||||
|              */ | ||||
|             @Override | ||||
|             public void actionPerformed(ActionEvent e){ | ||||
| @@ -90,10 +93,11 @@ public class ManagerGui extends JFrame { | ||||
|         this.add(buttonBill); | ||||
|         this.add(buttonQuit); | ||||
|  | ||||
|         this.setVisible(true); | ||||
|     } | ||||
|  | ||||
|     private JLabel resize(JLabel Jlogo, String logoFilePath){ | ||||
|         //TODO put in listener for resize when frame is resize. | ||||
|         //TODO put in listener for resize when frame is resized. | ||||
|         int width = (int)Jlogo.getSize().getWidth(); | ||||
|         int height = (int)Jlogo.getSize().getHeight(); | ||||
|         height = height > 0 ? height:65; | ||||
| @@ -105,12 +109,11 @@ public class ManagerGui extends JFrame { | ||||
|  | ||||
|  | ||||
| /** | ||||
|  *  | ||||
|  * Create a row in the windows with a label and a spinner | ||||
|  */ | ||||
| class Row { | ||||
|     JLabel label; | ||||
|     JSpinner spinner; | ||||
|  | ||||
|     Row(String title){ | ||||
|         label = new JLabel(title); | ||||
|         spinner = new JSpinner(); | ||||
| @@ -118,7 +121,7 @@ class Row { | ||||
| } | ||||
|  | ||||
| /** | ||||
|  *  | ||||
|  * listener for detect the button | ||||
|  */ | ||||
| class ButtonListenerManager implements ActionListener { | ||||
|     JFrame Jf; | ||||
|   | ||||
| @@ -1,5 +1,4 @@ | ||||
| package GUI; | ||||
| //TODO mettre commentaire | ||||
|  | ||||
| import javax.swing.*; | ||||
|  | ||||
| @@ -8,36 +7,43 @@ import java.awt.FlowLayout; | ||||
| import java.awt.event.ActionEvent; | ||||
| import java.awt.event.ActionListener; | ||||
|  | ||||
|  | ||||
| /** | ||||
|  * main class for create the window | ||||
|  */ | ||||
| public class GUI1 extends JFrame { | ||||
|     public static void main(String[] args) { | ||||
|         new GUI1(); | ||||
|     } | ||||
|  | ||||
|     GUI1(){ | ||||
|         //set up the window | ||||
|         setTitle("Me"); | ||||
|         setSize(200,200); | ||||
|         setLocation(600,200); | ||||
|         this.getContentPane().setBackground(Color.GREEN); | ||||
|  | ||||
|         //set the layout for the window | ||||
|         FlowLayout fl = new FlowLayout(); | ||||
| 		this.setLayout(fl); | ||||
|  | ||||
|         this.getContentPane().setBackground(Color.GREEN); | ||||
|  | ||||
|         //create and add component on the window | ||||
|         JButton jb1 = new JButton("Foo"); | ||||
|         JButton jb2 = new JButton("bar"); | ||||
|  | ||||
|         ButtonListener bl = new ButtonListener(this); | ||||
| 		jb1.addActionListener(bl); | ||||
|         jb2.addActionListener(bl); | ||||
|  | ||||
|  | ||||
|         this.add(jb1); | ||||
|         this.add(jb2); | ||||
|  | ||||
|  | ||||
|         this.setVisible(true); | ||||
|  | ||||
|     } | ||||
| } | ||||
|  | ||||
| /** | ||||
|  * set up the class for detect button | ||||
|  */ | ||||
| class ButtonListener implements ActionListener{ | ||||
| 	JFrame f1; | ||||
| 	 | ||||
|   | ||||
| @@ -1,5 +1,4 @@ | ||||
| package GUI; | ||||
| //TODO mettre commentaire | ||||
|  | ||||
| import javax.swing.*; | ||||
| import javax.swing.event.ChangeEvent; | ||||
| @@ -7,57 +6,53 @@ import javax.swing.event.ChangeListener; | ||||
| import java.awt.Container; | ||||
|  | ||||
| /** | ||||
|  *  | ||||
|  * main class for create the window | ||||
|  */ | ||||
| public class GUI2 extends JFrame{ | ||||
|     int number; | ||||
|     public static void main(String[] args) { | ||||
|         new GUI2(); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      *  | ||||
|      */ | ||||
|     GUI2(){ | ||||
|         //set up the window with the layout | ||||
|         setSize(200,200); | ||||
|         setLocation(600,200); | ||||
|         Container c = this.getContentPane(); | ||||
|         BoxLayout fl = new BoxLayout(c, BoxLayout.Y_AXIS); | ||||
| 		c.setLayout(fl); | ||||
|  | ||||
|         //create component on the window | ||||
|         JSlider js1 = new JSlider(0, 100); | ||||
|         js1.setValue(0); | ||||
|         JProgressBar jp1 = new JProgressBar(0, 100); | ||||
|         JLabel jl1 = new JLabel("waiting"); | ||||
|  | ||||
|         //create the listener for the slider | ||||
|         Listener l = new Listener(jp1, jl1, js1); | ||||
|         js1.addChangeListener(l); | ||||
|  | ||||
|         //addd component on the window | ||||
|         c.add(js1); | ||||
|         c.add(jp1); | ||||
|         c.add(jl1); | ||||
|  | ||||
|         this.setVisible(true); | ||||
|     } | ||||
|  | ||||
|  | ||||
| } | ||||
|  | ||||
| /** | ||||
|  *  | ||||
|  * class for detect slider mouvement | ||||
|  */ | ||||
| class Listener implements ChangeListener { | ||||
| 	JProgressBar jp1; | ||||
|     JLabel jl1; | ||||
|     JSlider js1; | ||||
|  | ||||
|     int number = 0; | ||||
| 	 | ||||
|     /** | ||||
|      *  | ||||
|      * @param jp1 | ||||
|      * @param jl1 | ||||
|      * @param js1 | ||||
|      * initialize the instance with parameters | ||||
|      * @param jp1 progress bar who display the number of the slider | ||||
|      * @param jl1 label progress bar who display the number of the slider | ||||
|      * @param js1 slider who modify the label and the progress bar | ||||
|      */ | ||||
| 	Listener(JProgressBar jp1, JLabel jl1, JSlider js1){ | ||||
| 		this.jp1 = jp1; | ||||
| @@ -66,8 +61,7 @@ class Listener implements ChangeListener { | ||||
| 	} | ||||
| 	 | ||||
|     /** | ||||
|      *  | ||||
|      * @param e | ||||
|      * modify the value of the label and the progress bar with the slider | ||||
|      */ | ||||
|     @Override | ||||
|     public void stateChanged(ChangeEvent e) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user