Début grille aec pion sans rien d'autre
This commit is contained in:
		
							
								
								
									
										5987
									
								
								diagrammeClasses.mdj
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5987
									
								
								diagrammeClasses.mdj
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
							
								
								
									
										0
									
								
								projetAgile/Main.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										0
									
								
								projetAgile/Main.java
									
									
									
									
									
										Normal file
									
								
							
							
								
								
									
										68
									
								
								projetAgile/Makefile
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										68
									
								
								projetAgile/Makefile
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,68 @@ | ||||
| JAVAC_OPT = -implicit:none \ | ||||
| 			-d build -classpath build -sourcepath src | ||||
| PACKAGE = fr.iutfbleau.projetAgile | ||||
| PACKAGE_PATH = fr/iutfbleau/projetAgile | ||||
| JAR_OPTION = cvfe projetAgile.jar $(PACKAGE).main.Main -C build fr -C res | ||||
|  | ||||
| #Modele  | ||||
|  | ||||
| jar : View modele controleur | ||||
| 	jar $(JAR_OPTION) | ||||
|  | ||||
| View : 	build/$(PACKAGE_PATH)/View/Fenetre.class \ | ||||
| 		build/$(PACKAGE_PATH)/View/Pion.class \ | ||||
| 		build/$(PACKAGE_PATH)/View/Grille.class | ||||
|  | ||||
| build/$(PACKAGE_PATH)/View/TestView.class : src/$(PACKAGE_PATH)/View/TestView.java build/$(PACKAGE_PATH)/View/Pion.class  | ||||
| 	javac $(JAVAC_OPT) src/$(PACKAGE_PATH)/View/TestView.java | ||||
|  | ||||
| build/$(PACKAGE_PATH)/View/Fenetre.class : 	src/$(PACKAGE_PATH)/View/Fenetre.java \ | ||||
| 											build/$(PACKAGE_PATH)/modele/Question.class | ||||
| 	javac $(JAVAC_OPT) src/$(PACKAGE_PATH)/View/Fenetre.java | ||||
|  | ||||
| build/$(PACKAGE_PATH)/View/Pion.class : 	src/$(PACKAGE_PATH)/View/Pion.java \ | ||||
| 												build/$(PACKAGE_PATH)/View/Fenetre.class  | ||||
| 	javac $(JAVAC_OPT) src/$(PACKAGE_PATH)/View/Pion.java | ||||
|  | ||||
| build/$(PACKAGE_PATH)/View/Grille.class : src/$(PACKAGE_PATH)/View/Grille.java  | ||||
| 	javac $(JAVAC_OPT) src/$(PACKAGE_PATH)/View/Grille.java | ||||
|  | ||||
| testView : View build/$(PACKAGE_PATH)/View/TestView.class | ||||
| 	java -cp build $(PACKAGE).View.TestView | ||||
|  | ||||
| modele : 	build/$(PACKAGE_PATH)/modele/QuestionSource.class \ | ||||
| 			build/$(PACKAGE_PATH)/modele/Question.class \ | ||||
| 			build/$(PACKAGE_PATH)/modele/QuestionChoices.class | ||||
|  | ||||
| build/$(PACKAGE_PATH)/modele/TestModele.class : modele | ||||
| 	javac $(JAVAC_OPT) src/$(PACKAGE_PATH)/modele/TestModele.java | ||||
|  | ||||
| build/$(PACKAGE_PATH)/modele/QuestionSource.class : src/$(PACKAGE_PATH)/modele/QuestionSource.java \ | ||||
| 													build/$(PACKAGE_PATH)/modele/Question.class build/$(PACKAGE_PATH)/modele/QuestionChoices.class  | ||||
| 	javac $(JAVAC_OPT) src/$(PACKAGE_PATH)/modele/QuestionSource.java | ||||
|  | ||||
| build/$(PACKAGE_PATH)/modele/Question.class : 	src/$(PACKAGE_PATH)/modele/Question.java \ | ||||
| 												build/$(PACKAGE_PATH)/modele/QuestionChoices.class  | ||||
| 	javac $(JAVAC_OPT) src/$(PACKAGE_PATH)/modele/Question.java | ||||
|  | ||||
| build/$(PACKAGE_PATH)/modele/QuestionChoices.class : src/$(PACKAGE_PATH)/modele/QuestionChoices.java  | ||||
| 	javac $(JAVAC_OPT) src/$(PACKAGE_PATH)/modele/QuestionChoices.java | ||||
|  | ||||
| testModele : modele build/$(PACKAGE_PATH)/modele/TestModele.class | ||||
| 	java -cp build $(PACKAGE).modele.TestModele | ||||
|  | ||||
| controleur : 	build/$(PACKAGE_PATH)/controleur/ChoiceValidation.class \ | ||||
| 				build/$(PACKAGE_PATH)/controleur/Navigation.class \ | ||||
| 				build/$(PACKAGE_PATH)/controleur/Startup.class | ||||
|  | ||||
| build/$(PACKAGE_PATH)/controleur/ChoiceValidation.class : src/$(PACKAGE_PATH)/controleur/ChoiceValidation.java build/$(PACKAGE_PATH)/View/Fenetre.class  | ||||
| 	javac $(JAVAC_OPT) src/$(PACKAGE_PATH)/controleur/ChoiceValidation.java | ||||
|  | ||||
| build/$(PACKAGE_PATH)/controleur/Navigation.class : src/$(PACKAGE_PATH)/controleur/Navigation.java  | ||||
| 	javac $(JAVAC_OPT) src/$(PACKAGE_PATH)/controleur/Navigation.java | ||||
|  | ||||
| build/$(PACKAGE_PATH)/controleur/Startup.class : src/$(PACKAGE_PATH)/controleur/Startup.java | ||||
| 	javac $(JAVAC_OPT) src/$(PACKAGE_PATH)/controleur/Startup.java | ||||
|  | ||||
| clear :  | ||||
| 	rm -rf build/* | ||||
							
								
								
									
										11
									
								
								projetAgile/src/fr/iutfbleau/projetAgile/Utils.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										11
									
								
								projetAgile/src/fr/iutfbleau/projetAgile/Utils.java
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,11 @@ | ||||
| import java.awt.Color; | ||||
|  | ||||
| public class Utils { | ||||
|     public final static Color PLAYER_ONE_COLOR = Color.RED; | ||||
|     public final static Color PLAYER_TWO_COLOR = Color.YELLOW; | ||||
|     public final static int PLAYER_ONE = 0; | ||||
|     public final static int PLAYER_TWO = 1; | ||||
|     public static int PAWN_MARGIN = 10; | ||||
|     public static int COLUMN_COUNT = 7; | ||||
|     public static int ROW_COUNT = 6; | ||||
| } | ||||
							
								
								
									
										27
									
								
								projetAgile/src/fr/iutfbleau/projetAgile/View/Fenetre.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										27
									
								
								projetAgile/src/fr/iutfbleau/projetAgile/View/Fenetre.java
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,27 @@ | ||||
| import javax.swing.*; | ||||
| import java.awt.*; | ||||
|  | ||||
| public class Fenetre extends JFrame{ | ||||
|     public Fenetre() { | ||||
|         super("Puissance 4"); | ||||
|         this.setLayout(new GridBagLayout()); | ||||
|         Grille g = new Grille(); | ||||
|         this.setLocation(200, 200); | ||||
|         this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); | ||||
|         GridBagConstraints gbc = new GridBagConstraints(); | ||||
|         gbc.gridx = 1; | ||||
|         gbc.gridy = 1; | ||||
|         gbc.fill = GridBagConstraints.NONE; | ||||
|         gbc.anchor = GridBagConstraints.CENTER; | ||||
|         gbc.gridwidth = 1; | ||||
|         gbc.gridheight = 1; | ||||
|         gbc.weightx = 0; | ||||
|         gbc.weighty = 0; | ||||
|         gbc.insets = new Insets(0, 0, 0, 0); | ||||
|         this.add(g, gbc); | ||||
|         this.setMinimumSize(g.getMinimumSize()); | ||||
|         this.pack(); | ||||
|         this.setVisible(true); | ||||
|         g.requestFocusInWindow(); | ||||
|     } | ||||
| } | ||||
							
								
								
									
										67
									
								
								projetAgile/src/fr/iutfbleau/projetAgile/View/Grille.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										67
									
								
								projetAgile/src/fr/iutfbleau/projetAgile/View/Grille.java
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,67 @@ | ||||
| import javax.swing.*; | ||||
| import java.awt.*; | ||||
|  | ||||
| public class Grille extends JPanel { | ||||
|  | ||||
|     private Pion grille[][]; | ||||
|     private int playerTurn = Utils.PLAYER_ONE; | ||||
|  | ||||
|     public Grille() { | ||||
|         super(); | ||||
|         this.init(); | ||||
|     } | ||||
|  | ||||
|     // public void drawPlayerPlay(int column, int player) { | ||||
|     //     for (int row = Utils.ROW_COUNT - 1; row >= 0; row--) { | ||||
|     //         Pion p = grille[column][row]; | ||||
|     //         if (p.getBackground() != Utils.PLAYER_ONE_COLOR && p.getBackground() != Utils.PLAYER_TWO_COLOR) { | ||||
|     //             p.setBackground(player == Utils.PLAYER_ONE ? Utils.PLAYER_ONE_COLOR : Utils.PLAYER_TWO_COLOR); | ||||
|     //             this.switchPlayer(); | ||||
|     //             break; | ||||
|     //         } | ||||
|     //     } | ||||
|     // } | ||||
|  | ||||
|     protected void init() { | ||||
|          /* | ||||
|          * On peut remplacer GridBagLayout par un GridLayout | ||||
|          */ | ||||
|         GridBagLayout gbl = new GridBagLayout(); | ||||
|         this.setLayout(gbl); | ||||
|         GridBagConstraints gbc = new GridBagConstraints(); | ||||
|         grille = new Pion[Utils.COLUMN_COUNT][Utils.ROW_COUNT]; | ||||
|         for (int x = 0; x < Utils.COLUMN_COUNT; x++) { | ||||
|             for (int y = 0; y < Utils.ROW_COUNT; y++) { | ||||
|                 Pion pion = new Pion(); | ||||
|                 gbc.gridx = x; | ||||
|                 gbc.gridy = y; | ||||
|                 gbc.fill = GridBagConstraints.BOTH; | ||||
|                 gbc.anchor = GridBagConstraints.CENTER; | ||||
|                 gbc.gridwidth = 1; | ||||
|                 gbc.gridheight = 1; | ||||
|                 gbc.weightx = 0; | ||||
|                 gbc.weighty = 0; | ||||
|                 gbc.insets = new Insets(0, 0, 0, 0); | ||||
|  | ||||
|                 this.add(pion, gbc); | ||||
|  | ||||
|                 grille[x][y] = pion; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         int minimumWidth = Utils.COLUMN_COUNT * Pion.getPionMinimumSize().width; | ||||
|         int minimumHeight = Utils.ROW_COUNT * Pion.getPionMinimumSize().height; | ||||
|         int preferredWidth = Utils.COLUMN_COUNT * Pion.getPionPreferredSize().width; | ||||
|         int preferredHeight = Utils.ROW_COUNT * Pion.getPionPreferredSize().height; | ||||
|          | ||||
|         this.setMinimumSize(new Dimension(minimumWidth, minimumHeight)); | ||||
|         this.setPreferredSize(new Dimension(preferredWidth, preferredHeight)); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     protected void paintComponent(Graphics g) { | ||||
|         Graphics g2 = g.create(); | ||||
|         g2.setColor(Color.BLUE); | ||||
|         g2.fillRoundRect(0, 0, this.getWidth(), this.getHeight(), 3 * Utils.PAWN_MARGIN, 3 * Utils.PAWN_MARGIN); | ||||
|     } | ||||
| }    | ||||
							
								
								
									
										35
									
								
								projetAgile/src/fr/iutfbleau/projetAgile/View/Pion.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								projetAgile/src/fr/iutfbleau/projetAgile/View/Pion.java
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,35 @@ | ||||
| import java.awt.*; | ||||
| import javax.swing.*; | ||||
|  | ||||
| public class Pion extends JComponent{ | ||||
|  | ||||
|     public static Dimension getPionMinimumSize() { | ||||
|         return new Dimension(80,80); | ||||
|     } | ||||
|  | ||||
|     public static Dimension getPionMaximumSize() { | ||||
|         return new Dimension(150,150); | ||||
|     } | ||||
|  | ||||
|     public static Dimension getPionPreferredSize() { | ||||
|         return new Dimension(120,120); | ||||
|     } | ||||
|  | ||||
|     public Pion() { | ||||
|         this.setMinimumSize(new Dimension(80,80)); | ||||
|         this.setMaximumSize(new Dimension(150,150)); | ||||
|         this.setPreferredSize(new Dimension(120,120)); | ||||
|         this.setBackground(Color.WHITE); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     protected void paintComponent(Graphics g) { | ||||
|         Graphics g2 = g.create(); | ||||
|         //g2.setColor(Color.BLUE); | ||||
|         //g2.fillRect(0, 0, this.getWidth(), this.getHeight()); | ||||
|         g2.setColor(Color.GRAY); | ||||
|         g2.fillOval((int) (Utils.PAWN_MARGIN * 1.2),(int) (Utils.PAWN_MARGIN * 1.1) , this.getWidth() - 2 * Utils.PAWN_MARGIN, this.getHeight() - 2 * Utils.PAWN_MARGIN + 2); | ||||
|         g2.setColor(this.getBackground()); | ||||
|         g2.fillOval(Utils.PAWN_MARGIN, Utils.PAWN_MARGIN, this.getWidth() - 2 * Utils.PAWN_MARGIN, this.getHeight() - 2 * Utils.PAWN_MARGIN); | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user