diff --git a/2A/Java/tp/JavaFX/tpJeuDeL_oie/.idea/.gitignore b/2A/Java/tp/JavaFX/tpJeuDeL_oie/.idea/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/2A/Java/tp/JavaFX/tpJeuDeL_oie/.idea/misc.xml b/2A/Java/tp/JavaFX/tpJeuDeL_oie/.idea/misc.xml new file mode 100644 index 0000000..639900d --- /dev/null +++ b/2A/Java/tp/JavaFX/tpJeuDeL_oie/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/2A/Java/tp/JavaFX/tpJeuDeL_oie/.idea/modules.xml b/2A/Java/tp/JavaFX/tpJeuDeL_oie/.idea/modules.xml new file mode 100644 index 0000000..def6ce6 --- /dev/null +++ b/2A/Java/tp/JavaFX/tpJeuDeL_oie/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/2A/Java/tp/JavaFX/tpJeuDeL_oie/.idea/tpJeuDeL_oie.iml b/2A/Java/tp/JavaFX/tpJeuDeL_oie/.idea/tpJeuDeL_oie.iml new file mode 100644 index 0000000..d6ebd48 --- /dev/null +++ b/2A/Java/tp/JavaFX/tpJeuDeL_oie/.idea/tpJeuDeL_oie.iml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/2A/Java/tp/JavaFX/tpJeuDeL_oie/.idea/vcs.xml b/2A/Java/tp/JavaFX/tpJeuDeL_oie/.idea/vcs.xml new file mode 100644 index 0000000..bc59970 --- /dev/null +++ b/2A/Java/tp/JavaFX/tpJeuDeL_oie/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/2A/Java/tp/JavaFX/tpJeuDeL_oie/.idea/workspace.xml b/2A/Java/tp/JavaFX/tpJeuDeL_oie/.idea/workspace.xml new file mode 100644 index 0000000..098af3c --- /dev/null +++ b/2A/Java/tp/JavaFX/tpJeuDeL_oie/.idea/workspace.xml @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + 1702623908454 + + + + \ No newline at end of file diff --git a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/.idea/.gitignore b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/.idea/.gitignore new file mode 100644 index 0000000..26d3352 --- /dev/null +++ b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/.idea/.gitignore @@ -0,0 +1,3 @@ +# Default ignored files +/shelf/ +/workspace.xml diff --git a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/.idea/misc.xml b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/.idea/misc.xml new file mode 100644 index 0000000..a346fd7 --- /dev/null +++ b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/.idea/modules.xml b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/.idea/modules.xml new file mode 100644 index 0000000..248ea68 --- /dev/null +++ b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/.idea/vcs.xml b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/.idea/vcs.xml new file mode 100644 index 0000000..821e530 --- /dev/null +++ b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/Oie.iml b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/Oie.iml new file mode 100644 index 0000000..9d6237f --- /dev/null +++ b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/Oie.iml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/data/Stub.class b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/data/Stub.class new file mode 100644 index 0000000..bc30cca Binary files /dev/null and b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/data/Stub.class differ diff --git a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/fxml/Fenetre.fxml b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/fxml/Fenetre.fxml new file mode 100644 index 0000000..2d535f3 --- /dev/null +++ b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/fxml/Fenetre.fxml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/launcher/ConsoleGame.class b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/launcher/ConsoleGame.class new file mode 100644 index 0000000..e2f5c31 Binary files /dev/null and b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/launcher/ConsoleGame.class differ diff --git a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/launcher/GraphicGame.class b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/launcher/GraphicGame.class new file mode 100644 index 0000000..2c8ca73 Binary files /dev/null and b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/launcher/GraphicGame.class differ diff --git a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/models/Case.class b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/models/Case.class new file mode 100644 index 0000000..9329091 Binary files /dev/null and b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/models/Case.class differ diff --git a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/models/Jeu.class b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/models/Jeu.class new file mode 100644 index 0000000..658b924 Binary files /dev/null and b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/models/Jeu.class differ diff --git a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/models/Pion.class b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/models/Pion.class new file mode 100644 index 0000000..0823653 Binary files /dev/null and b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/models/Pion.class differ diff --git a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/models/Plateau.class b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/models/Plateau.class new file mode 100644 index 0000000..fcea6ce Binary files /dev/null and b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/models/Plateau.class differ diff --git a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/view/Fenetre.class b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/view/Fenetre.class new file mode 100644 index 0000000..16a888c Binary files /dev/null and b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/out/production/Oie/view/Fenetre.class differ diff --git a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/res/fxml/Fenetre.fxml b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/res/fxml/Fenetre.fxml new file mode 100644 index 0000000..2d535f3 --- /dev/null +++ b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/res/fxml/Fenetre.fxml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/src/data/Stub.java b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/src/data/Stub.java new file mode 100644 index 0000000..42bcf22 --- /dev/null +++ b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/src/data/Stub.java @@ -0,0 +1,15 @@ +package data; + +import models.Jeu; +import models.Pion; +import models.Plateau; + +public class Stub { + public Jeu loadPions() { + Plateau myPlateau = new Plateau(5); + Jeu game = new Jeu(myPlateau); + game.addPion(new Pion("rouge")); + game.addPion(new Pion("bleu")); + return game; + } +} diff --git a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/src/launcher/ConsoleGame.java b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/src/launcher/ConsoleGame.java new file mode 100644 index 0000000..e9118db --- /dev/null +++ b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/src/launcher/ConsoleGame.java @@ -0,0 +1,24 @@ +package launcher; + +import data.Stub; +import models.Jeu; +import models.Pion; + +public class ConsoleGame { + + public static void main(String[] args) { + final Jeu game = new Stub().loadPions(); + System.out.println(game.getPlateau().toString()); + Pion currentPion = game.getCurrentPion(); + System.out.println(currentPion.toString()); + System.out.println("Changement de Pion"); + currentPion = game.changePion(); + System.out.println(currentPion.toString()); + game.avancerPion(); + System.out.println(currentPion.toString()); + System.out.println(game.getPlateau().toString()); + game.avancerPion(); + System.out.println(currentPion.toString()); + System.out.println(game.getPlateau().toString()); + } +} diff --git a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/src/launcher/GraphicGame.java b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/src/launcher/GraphicGame.java new file mode 100644 index 0000000..d068c4d --- /dev/null +++ b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/src/launcher/GraphicGame.java @@ -0,0 +1,18 @@ +package launcher; + +import javafx.application.Application; +import javafx.fxml.FXMLLoader; +import javafx.scene.Parent; +import javafx.scene.Scene; +import javafx.stage.Stage; + +public class GraphicGame extends Application { + @Override + public void start(Stage primaryStage) throws Exception { + FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/Fenetre.fxml")); + Parent root = loader.load(); + + primaryStage.setScene(new Scene(root, 700, 500)); + primaryStage.show(); + } +} diff --git a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/src/models/Case.java b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/src/models/Case.java new file mode 100644 index 0000000..759a91d --- /dev/null +++ b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/src/models/Case.java @@ -0,0 +1,21 @@ +package models; + +public class Case { + private int idCase; + private boolean presence; + public Case(int i){ + idCase = i; + presence = false; + } + public boolean getPresence() { + return this.presence; + } + public void setPresence(boolean presence) { + this.presence = presence; + } + + @Override + public String toString() { + return this.idCase + " " + this.presence + "\n"; + } +} diff --git a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/src/models/Jeu.java b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/src/models/Jeu.java new file mode 100644 index 0000000..7cfdb4e --- /dev/null +++ b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/src/models/Jeu.java @@ -0,0 +1,36 @@ +package models; + +import java.util.ArrayList; +import java.util.List; + +public class Jeu { + private Plateau myPlateau; + private List pionsList = new ArrayList<>(); + private int currentPionId = 0; + public Jeu(Plateau myPlateau) { + this.myPlateau = myPlateau; + } + public Plateau getPlateau() { + return this.myPlateau; + } + public List getPionsList() { + return this.pionsList; + } + public Pion getCurrentPion() { + return pionsList.get(currentPionId); + } + public Pion changePion() { + return pionsList.get(++currentPionId % pionsList.size()); + } + public void avancerPion() { + Pion currentPion = pionsList.get(currentPionId); + if(currentPion.getCurrentIdCase() != 0) { + this.myPlateau.getCaseList().get(currentPion.getCurrentIdCase() - 1).setPresence(false); + } + currentPion.setCurrentIdCase(); + this.myPlateau.getCaseList().get(currentPion.getCurrentIdCase()-1).setPresence(true); + } + public void addPion(Pion pion) { + pionsList.add(pion); + } +} diff --git a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/src/models/Pion.java b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/src/models/Pion.java new file mode 100644 index 0000000..c819143 --- /dev/null +++ b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/src/models/Pion.java @@ -0,0 +1,22 @@ +package models; + +public class Pion { + private String color; + private int idCase = 0; + public Pion(String myColor) { + this.color = myColor; + } + public String getColor() { + return color; + } + public int getCurrentIdCase() { + return this.idCase; + } + public void setCurrentIdCase() { + this.idCase++; + } + @Override + public String toString() { + return "Je suis le Pion de couleur " + this.color + " et je suis sur la case " + this.idCase; + } +} diff --git a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/src/models/Plateau.java b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/src/models/Plateau.java new file mode 100644 index 0000000..a214333 --- /dev/null +++ b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/src/models/Plateau.java @@ -0,0 +1,31 @@ +package models; + +import java.util.ArrayList; +import java.util.List; + +public class Plateau { + private List CaseList = new ArrayList<>(); + public Plateau(int nbCase) { + for(int i = 1; i <= nbCase; ++i) { + CaseList.add(new Case(i)); + } + } + public List getCaseList() { + return this.CaseList; + } + public boolean addCaseList(Case myCase) { + return this.CaseList.add(myCase); + } + public boolean removeCaseList(Case myCase) { + return this.CaseList.remove(myCase); + } + + @Override + public String toString() { + String plateau = ""; + for(int i = 0; i < CaseList.size(); i++) { + plateau = plateau.concat(CaseList.get(i).toString()); + } + return plateau; + } +} diff --git a/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/src/view/Fenetre.java b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/src/view/Fenetre.java new file mode 100644 index 0000000..3048642 --- /dev/null +++ b/2A/Java/tp/JavaFX/tpJeuDeL_oie/Oie/src/view/Fenetre.java @@ -0,0 +1,23 @@ +package view; + +import data.Stub; +import javafx.fxml.FXML; +import javafx.scene.control.Button; +import javafx.scene.layout.BorderPane; +import models.Jeu; +import models.Pion; + +import java.awt.*; + +public class Fenetre { + @FXML + private BorderPane myBorderPane = new BorderPane(); + private final Jeu game = new Stub().loadPions(); + Pion currentPion = game.getCurrentPion(); + + public void initialize() { + for(int i = 0; i < game.getPlateau().getCaseList().size(); i++) { + myBorderPane.setCenter(new Button().setText("hello")); + } + } +}