main
ZIRTR0X 3 years ago
parent 0ade4680d3
commit e9d8bb53c0

@ -10,4 +10,5 @@
23 1 21-01-22 23 1 21-01-22
24 1 21-01-22 24 1 21-01-22
25 1 21-01-22 25 1 21-01-22
26 1 21-01-22 26 1 21-01-2211 1 20-01-22
14 1 20-01-22

@ -41,11 +41,22 @@ public class CreatureController {
private Image imagePerso11; private Image imagePerso11;
private Image imagePerso12; private Image imagePerso12;
/**
* Constructor of the CreatureController class
* @param lv
* @param map
* @param creatureImageView
*/
public CreatureController(int lv,Map map, ImageView creatureImageView) { public CreatureController(int lv,Map map, ImageView creatureImageView) {
this.lv = lv; this.lv = lv;
this.map = map; this.map = map;
this.creatureImageView = creatureImageView; this.creatureImageView = creatureImageView;
} }
/**
* Method to create a creature
* @param animal
*/
public void createCreature(int animal) { public void createCreature(int animal) {
if(animal == 1) { if(animal == 1) {
this.creature = new Creature(1,"/image/creature/dog1.",0,0 ); this.creature = new Creature(1,"/image/creature/dog1.",0,0 );
@ -59,6 +70,10 @@ public class CreatureController {
} }
} }
/**
* Method to initialize the creature
* @throws InterruptedException
*/
public void playerInitialisation() throws InterruptedException { public void playerInitialisation() throws InterruptedException {
mapCreatureController = new MapCreatureController(lv, map); mapCreatureController = new MapCreatureController(lv, map);
mapCreatureController.creerMapCreature(); mapCreatureController.creerMapCreature();
@ -106,6 +121,10 @@ public class CreatureController {
} }
/**
* Method to move the creature to the next case
* @throws InterruptedException
*/
public void movePlayerNextCase() throws InterruptedException { public void movePlayerNextCase() throws InterruptedException {
caseAncienne = caseActuelle; caseAncienne = caseActuelle;
caseActuelle = mapCreatureController.getNextCase(caseActuelle); caseActuelle = mapCreatureController.getNextCase(caseActuelle);
@ -278,14 +297,28 @@ public class CreatureController {
timelines.play(); timelines.play();
} }
} }
/**
* Method to get the path of the image of the creature
* @return the path of the image of the creature
*/
public String getPath(){ public String getPath(){
return creature.getImage(); return creature.getImage();
} }
/**
* Method to get the X coordinate of the creature
* @return X coordinate
*/
public int getX(){ public int getX(){
return creature.getCoordX(); return creature.getCoordX();
} }
/**
* Method to get the Y coordinate of the creature
* @return Y coordinate
*/
public int getY(){ public int getY(){
return creature.getCoordY(); return creature.getCoordY();
} }

@ -35,6 +35,11 @@ public class GameConfigMenuController implements Initializable {
private int personnage; private int personnage;
private int difficulty; private int difficulty;
/**
* Initializes the controller class.
* @param url
* @param resourceBundle
*/
@Override @Override
public void initialize(URL url, ResourceBundle resourceBundle) { public void initialize(URL url, ResourceBundle resourceBundle) {
radioButton1.setToggleGroup(group); radioButton1.setToggleGroup(group);
@ -42,29 +47,62 @@ public class GameConfigMenuController implements Initializable {
radioButton3.setToggleGroup(group); radioButton3.setToggleGroup(group);
} }
/**
* Method to change the skin of the player one
* @param event
*/
@FXML void changeSkin1(ActionEvent event){ @FXML void changeSkin1(ActionEvent event){
ImageChange.setImage(new Image("/image/personnage/Perso1.2.png")); ImageChange.setImage(new Image("/image/personnage/Perso1.2.png"));
this.personnage = 1; this.personnage = 1;
} }
/**
* Method to change the skin of the player two
* @param event
*/
@FXML void changeSkin2(ActionEvent event){ @FXML void changeSkin2(ActionEvent event){
ImageChange.setImage(new Image("/image/personnage/Perso2.2.png")); ImageChange.setImage(new Image("/image/personnage/Perso2.2.png"));
this.personnage = 2; this.personnage = 2;
} }
/**
* Method to change the skin of the player three
* @param event
*/
@FXML void changeSkin3(ActionEvent event){ @FXML void changeSkin3(ActionEvent event){
ImageChange.setImage(new Image("/image/personnage/Perso3.2.png")); ImageChange.setImage(new Image("/image/personnage/Perso3.2.png"));
this.personnage = 3; this.personnage = 3;
} }
/**
* Method to set the difficulty to 1
* @param event
*/
@FXML void setDifficulty1(MouseEvent event){ @FXML void setDifficulty1(MouseEvent event){
this.difficulty = 1; this.difficulty = 1;
} }
/**
* Method to set the difficulty to 2
* @param event
*/
@FXML void setDifficulty2(MouseEvent event){ @FXML void setDifficulty2(MouseEvent event){
this.difficulty = 2; this.difficulty = 2;
} }
/**
* Method to set the difficulty to 3
* @param event
*/
@FXML void setDifficulty3(MouseEvent event){ @FXML void setDifficulty3(MouseEvent event){
this.difficulty = 3; this.difficulty = 3;
} }
/**
* Method to start the game
* @param event
* @throws Exception
*/
@FXML @FXML
void launchGame(MouseEvent event) throws Exception { void launchGame(MouseEvent event) throws Exception {
FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/viewGame2.fxml")); FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/viewGame2.fxml"));
@ -88,6 +126,11 @@ public class GameConfigMenuController implements Initializable {
stage.close(); stage.close();
} }
/**
* Method to go back to the main menu
* @param event
* @throws Exception
*/
@FXML @FXML
void returnToMenu(MouseEvent event) throws Exception{ void returnToMenu(MouseEvent event) throws Exception{
AnchorPane pane = FXMLLoader.load(Objects.requireNonNull(getClass().getResource("/fxml/MainPage.fxml"))); AnchorPane pane = FXMLLoader.load(Objects.requireNonNull(getClass().getResource("/fxml/MainPage.fxml")));

@ -66,11 +66,19 @@ public class GamePlayController implements Initializable {
private JFXButton button; private JFXButton button;
private Boolean PersoMouv; private Boolean PersoMouv;
/**
* Initializes the controller class.
* @param url
* @param resourceBundle
*/
@FXML @FXML
@Override @Override
public void initialize(URL url, ResourceBundle resourceBundle) { public void initialize(URL url, ResourceBundle resourceBundle) {
} }
/**
* Method to launch the game
*/
public void gameLauncher(){ public void gameLauncher(){
levelRoot.getChildren().addAll(mapController.mapInitialisation(this.difficulty), persoController.playerInitialisation(this.difficulty,this.perso, mapController.getMap()), creatureImageView); levelRoot.getChildren().addAll(mapController.mapInitialisation(this.difficulty), persoController.playerInitialisation(this.difficulty,this.perso, mapController.getMap()), creatureImageView);
persoController.setActualCase(mapController.getStartCase()); persoController.setActualCase(mapController.getStartCase());
@ -126,12 +134,15 @@ public class GamePlayController implements Initializable {
resultat5.setFill(Color.WHITE); resultat5.setFill(Color.WHITE);
resultat5.setStyle("-fx-font: 20 arial; "); resultat5.setStyle("-fx-font: 20 arial; ");
button = new JFXButton(""); button = new JFXButton("");
levelRoot.getChildren().addAll(text,textTimer,textEnd,button,resultat1,resultat2,resultat3,resultat4); levelRoot.getChildren().addAll(text,textTimer,textEnd,button, resultat1, resultat2, resultat3, resultat4, resultat5);
gameTime = new GameTime(textTimer); gameTime = new GameTime(textTimer);
gameTime.start(); gameTime.start();
PersoMouv = false; PersoMouv = false;
} }
/**
* Method to stop the gameTime and the gameLoop
*/
public void timer(){ public void timer(){
if(finJeu){ if(finJeu){
gameTime.stop(); gameTime.stop();
@ -139,6 +150,10 @@ public class GamePlayController implements Initializable {
} }
} }
/**
* Method to move the player to the next case
* @throws InterruptedException
*/
public void movePlayerNextCase() throws InterruptedException { public void movePlayerNextCase() throws InterruptedException {
persoImageView = persoController.persoImageView; persoImageView = persoController.persoImageView;
@ -329,8 +344,11 @@ public class GamePlayController implements Initializable {
} }
} }
/**
* Method to return to the start of the game
*/
public void returnToStart(){ public void returnToStart(){
button.setText("Restart"); button.setText("Exit");
button.setStyle("-fx-background-color: #EB9C0A; -fx-text-fill: white;"); button.setStyle("-fx-background-color: #EB9C0A; -fx-text-fill: white;");
button.setLayoutX(1071); button.setLayoutX(1071);
button.setLayoutY(752); button.setLayoutY(752);
@ -338,24 +356,14 @@ public class GamePlayController implements Initializable {
button.setPrefWidth(119); button.setPrefWidth(119);
button.setText("Retour au début"); button.setText("Retour au début");
button.setOnAction(event -> { button.setOnAction(event -> {
try { System.exit(0);
AnchorPane pane = FXMLLoader.load(Objects.requireNonNull(getClass().getResource("/fxml/MainPage.fxml")));
Stage a = new Stage();
a.setTitle("The Adventurer");
a.setScene(new Scene(pane, 900, 600));
a.setResizable(false);
a.show();
Stage stage = (Stage) levelRoot.getScene().getWindow();
stage.close();
levelRoot.getChildren().setAll(pane);
} catch (IOException e) {
e.printStackTrace();
}
} }
); );
} }
/**
* Method to lunch the dice
*/
public void lancerDe() { public void lancerDe() {
Case actuel = persoController.getActualCase();; Case actuel = persoController.getActualCase();;
@ -366,7 +374,9 @@ public class GamePlayController implements Initializable {
} }
/**
* Method to launch the animation of the dice
*/
public void animationDe() { public void animationDe() {
personnage = new Thread("personnage") { personnage = new Thread("personnage") {
@ -465,6 +475,10 @@ public class GamePlayController implements Initializable {
}; };
personnage.start(); personnage.start();
} }
/**
* Method to display the result of the dice
*/
public void affichageResultat(){ public void affichageResultat(){
String ancienResultat1; String ancienResultat1;
String ancienResultat2; String ancienResultat2;
@ -512,6 +526,9 @@ public class GamePlayController implements Initializable {
} }
} }
/**
* Method to save the score of the player
*/
public void saveScore(){ public void saveScore(){
//difficulty //difficulty
int resultat = gameTime.getTime(); int resultat = gameTime.getTime();

@ -31,31 +31,44 @@ public class MainPageController implements Initializable {
@FXML @FXML
private ImageView loadGame; private ImageView loadGame;
/**
* Initializes the controller class.
* @param url
* @param resourceBundle
*/
@Override @Override
public void initialize(URL url, ResourceBundle resourceBundle) { public void initialize(URL url, ResourceBundle resourceBundle) {
} }
/**
* Go to the score page
* @param event
* @throws Exception
*/
@FXML @FXML
void viewScore(MouseEvent event) throws Exception{ void viewScore(MouseEvent event) throws Exception{
AnchorPane pane = FXMLLoader.load(Objects.requireNonNull(getClass().getResource("/fxml/TopPlayers.fxml"))); AnchorPane pane = FXMLLoader.load(Objects.requireNonNull(getClass().getResource("/fxml/TopPlayers.fxml")));
mainRoot.getChildren().setAll(pane); mainRoot.getChildren().setAll(pane);
} }
/**
* Go to the game configuration page
* @param event
* @throws Exception
*/
@FXML @FXML
void startGame(MouseEvent event) throws Exception{ void startGame(MouseEvent event) throws Exception{
AnchorPane pane = FXMLLoader.load(Objects.requireNonNull(getClass().getResource("/fxml/GameConfigurationMenu.fxml"))); AnchorPane pane = FXMLLoader.load(Objects.requireNonNull(getClass().getResource("/fxml/GameConfigurationMenu.fxml")));
mainRoot.getChildren().setAll(pane); mainRoot.getChildren().setAll(pane);
} }
/**
* Exit the game
* @param event
*/
@FXML @FXML
void exitGame(MouseEvent event) { void exitGame(MouseEvent event) {
try{
Main.serialize();
}
catch(IOException e){
//System.out.println("Could not save the progress :(");
}
System.exit(0); System.exit(0);
} }
} }

@ -59,10 +59,19 @@ public class MapController implements Initializable {
private int[][] coordMap = {}; private int[][] coordMap = {};
private final int[][] coordFirstDifficultyMap = {{0,24},{1,24},{2,24},{3,24},{4,24},{5,24},{5,23},{5,22},{5,21}}; private final int[][] coordFirstDifficultyMap = {{0,24},{1,24},{2,24},{3,24},{4,24},{5,24},{5,23},{5,22},{5,21}};
/**
* Initializes the controller class.
* @param location
* @param resources
*/
@Override @Override
public void initialize(java.net.URL location, java.util.ResourceBundle resources) { public void initialize(java.net.URL location, java.util.ResourceBundle resources) {
} }
/**
* Method which create the map
* @param difficulty
*/
public void createMap(int difficulty) { public void createMap(int difficulty) {
int j = 1, k; int j = 1, k;
@ -98,6 +107,11 @@ public class MapController implements Initializable {
} }
} }
/**
* Method which initialize the map
* @param difficulty
* @return
*/
public AnchorPane mapInitialisation(int difficulty) { public AnchorPane mapInitialisation(int difficulty) {
int tileSize = 32; int tileSize = 32;
@ -467,22 +481,45 @@ public class MapController implements Initializable {
} }
} }
/**
* Method to get the map
* @return map
*/
public Map getMap(){ public Map getMap(){
return this.map; return this.map;
} }
/**
* Method to get the start case
* @return start case
*/
public Case getCaseStart(){ public Case getCaseStart(){
return map.getStartCase(); return map.getStartCase();
} }
/**
* Method which give the next case
* @param c
* @return next case
*/
public Case getNextCase(Case c){ public Case getNextCase(Case c){
return map.getNextCase(c); return map.getNextCase(c);
} }
/**
* Method which give the start case
* @return start case
*/
public Case getStartCase(){ public Case getStartCase(){
return map.getStartCase(); return map.getStartCase();
} }
/**
* Method to get the case which is num case after the case c
* @param c
* @param num
* @return
*/
public Case getCase(Case c, int num){ public Case getCase(Case c, int num){
return map.getCase(c, num); return map.getCase(c, num);
} }

@ -9,10 +9,20 @@ public class MapCreatureController {
private MapCreature mapCreature; private MapCreature mapCreature;
private Map map; private Map map;
private int[][] coordList; private int[][] coordList;
/**
* Constructor of MapCreatureController class
* @param lv
* @param map
*/
public MapCreatureController(int lv, Map map) { public MapCreatureController(int lv, Map map) {
this.lv = lv; this.lv = lv;
this.map = map; this.map = map;
} }
/**
* Method to create a MapCreature
*/
public void creerMapCreature() { public void creerMapCreature() {
int[][] coord1Lv1 = {{0,-1},{0,0},{1,0},{2,0},{3,0},{3,1},{4,1},{5,1},{6,1},{7,1},{8,1},{9,1},{9,2},{10,2},{11,2},{12,2},{13,2},{14,2},{15,2},{16,2},{17,2},{18,2},{19,2},{20,2},{21,2},{21,3},{21,4},{22,4},{23,4},{24,4},{25,4},{25,5},{25,6},{26,6},{27,6},{28,6},{28,7},{28,8},{28,9},{28,10},{28,11},{28,12},{29,12},{30,12}}; int[][] coord1Lv1 = {{0,-1},{0,0},{1,0},{2,0},{3,0},{3,1},{4,1},{5,1},{6,1},{7,1},{8,1},{9,1},{9,2},{10,2},{11,2},{12,2},{13,2},{14,2},{15,2},{16,2},{17,2},{18,2},{19,2},{20,2},{21,2},{21,3},{21,4},{22,4},{23,4},{24,4},{25,4},{25,5},{25,6},{26,6},{27,6},{28,6},{28,7},{28,8},{28,9},{28,10},{28,11},{28,12},{29,12},{30,12}};
int[][] coord2Lv1 = {{30,27},{29,27},{28,27},{27,27},{26,27},{25,27},{24,27},{23,27},{23,26},{22,26},{21,26},{20,26},{20,25},{19,25},{18,25},{17,25},{16,25},{15,25},{14,25},{13,25},{13,24},{12,24},{11,24},{10,24},{9,24},{8,24},{7,24},{6,24},{6,25},{6,26},{5,26},{4,26},{3,26},{2,26},{1,26},{-1,26},{-2,26}}; int[][] coord2Lv1 = {{30,27},{29,27},{28,27},{27,27},{26,27},{25,27},{24,27},{23,27},{23,26},{22,26},{21,26},{20,26},{20,25},{19,25},{18,25},{17,25},{16,25},{15,25},{14,25},{13,25},{13,24},{12,24},{11,24},{10,24},{9,24},{8,24},{7,24},{6,24},{6,25},{6,26},{5,26},{4,26},{3,26},{2,26},{1,26},{-1,26},{-2,26}};
@ -20,9 +30,6 @@ public class MapCreatureController {
int[][] coord2Lv2 = {{30,22},{29,22},{28,22},{27,22},{26,22},{25,22},{24,22},{24,21},{23,21},{22,21},{22,20},{21,20},{20,20},{19,20},{18,20},{17,20},{17,19},{16,19},{15,19},{14,19},{14,18},{13,18},{13,17},{13,16},{14,16},{15,16},{16,16},{17,16},{17,17},{18,17},{19,17},{20,17},{21,17},{21,16},{21,15},{22,15},{23,15},{24,15},{25,15},{26,15},{26,14},{27,14},{28,14},{28,13},{28,12},{29,12},{30,12}}; int[][] coord2Lv2 = {{30,22},{29,22},{28,22},{27,22},{26,22},{25,22},{24,22},{24,21},{23,21},{22,21},{22,20},{21,20},{20,20},{19,20},{18,20},{17,20},{17,19},{16,19},{15,19},{14,19},{14,18},{13,18},{13,17},{13,16},{14,16},{15,16},{16,16},{17,16},{17,17},{18,17},{19,17},{20,17},{21,17},{21,16},{21,15},{22,15},{23,15},{24,15},{25,15},{26,15},{26,14},{27,14},{28,14},{28,13},{28,12},{29,12},{30,12}};
int[][] coord1Lv3 = {{30,4},{29,4},{28,4},{27,4},{26,4},{25,4},{24,4},{23,4},{23,5},{23,6},{23,7},{22,7},{21,7},{20,7},{20,6},{19,6},{19,5},{19,4},{18,4},{17,4},{17,5},{17,6},{17,7},{18,7},{18,8},{19,8},{20,8},{21,8},{22,8},{23,8},{24,8},{24,9},{25,9},{26,9},{27,9},{28,9},{29,9},{30,9}}; int[][] coord1Lv3 = {{30,4},{29,4},{28,4},{27,4},{26,4},{25,4},{24,4},{23,4},{23,5},{23,6},{23,7},{22,7},{21,7},{20,7},{20,6},{19,6},{19,5},{19,4},{18,4},{17,4},{17,5},{17,6},{17,7},{18,7},{18,8},{19,8},{20,8},{21,8},{22,8},{23,8},{24,8},{24,9},{25,9},{26,9},{27,9},{28,9},{29,9},{30,9}};
int[][] coord2Lv3 = {{-1,7},{0,7},{1,7},{2,7},{2,8},{3,8},{4,8},{4,9},{5,9},{6,9},{7,9},{8,9},{9,9},{9,10},{10,10},{11,10},{12,10},{13,10},{14,10},{14,11},{14,12},{15,12},{15,13},{14,13},{13,13},{12,13},{11,13},{11,12},{11,11},{11,10},{10,10},{9,10},{8,10},{8,11},{7,11},{7,12},{7,13},{6,13},{5,13},{4,13},{4,12},{4,11},{4,10},{3,10},{2,10},{1,10},{0,10},{-1,10}}; int[][] coord2Lv3 = {{-1,7},{0,7},{1,7},{2,7},{2,8},{3,8},{4,8},{4,9},{5,9},{6,9},{7,9},{8,9},{9,9},{9,10},{10,10},{11,10},{12,10},{13,10},{14,10},{14,11},{14,12},{15,12},{15,13},{14,13},{13,13},{12,13},{11,13},{11,12},{11,11},{11,10},{10,10},{9,10},{8,10},{8,11},{7,11},{7,12},{7,13},{6,13},{5,13},{4,13},{4,12},{4,11},{4,10},{3,10},{2,10},{1,10},{0,10},{-1,10}};
//int[][] coordLv1 = {{1,0},{2,0},{3,0},{4,0},{5,0},{6,0},{7,0},{8,0},{9,0}};
//int[][] coordLv1 = {{0,24},{1,24},{2,24},{3,24},{4,24},{5,24},{5,23},{5,22},{5,21},{5,20},{5,19},{5,18},{6,18},{7,18},{8,18},{9,18},{10,18},{11,18},{12,18},{12,17},{12,16},{12,15},{12,14},{12,13},{12,12},{11,12},{10,12},{9,12},{8,12},{7,12},{6,12},{5,12},{4,12},{3,12},{3,11},{3,10},{3,9},{3,8},{3,7},{3,6},{3,5},{3,4},{3,3},{4,3},{5,3},{6,3},{7,3},{8,3},{9,3},{10,3},{11,3},{12,3},{13,3},{14,3},{15,3},{16,3},{17,3},{18,3},{19,3},{19,4},{19,5},{19,6},{19,7},{19,8},{19,9},{19,10},{20,10},{21,10},{22,10},{23,10},{24,10},{24,11},{24,12},{24,13},{24,14},{24,15},{24,16},{24,17},{24,18},{24,19},{24,20},{24,21},{24,22},{24,23},{24,24},{25,24},{26,24},{27,24},{28,24},{29,24}};
mapCreature = new MapCreature(map.getSizeTile(), map.getSizeMap()); mapCreature = new MapCreature(map.getSizeTile(), map.getSizeMap());
@ -74,18 +81,36 @@ public class MapCreatureController {
} }
} }
} }
/**
* Method to get the map
* @return creature's map
*/
public MapCreature getMap(){ public MapCreature getMap(){
return this.mapCreature; return this.mapCreature;
} }
/**
* Method to get the next case
* @param c
* @return case
*/
public Case getNextCase(Case c){ public Case getNextCase(Case c){
return mapCreature.getNextCase(c); return mapCreature.getNextCase(c);
} }
/**
* Method to get the start case
* @return case
*/
public Case getStartCase(){ public Case getStartCase(){
return mapCreature.getStartCase(); return mapCreature.getStartCase();
} }
/**
* Method to get the size of ListeCase
* @return size of ListeCase
*/
public int getSizeListeCase(){ public int getSizeListeCase(){
return coordList.length; return coordList.length;
} }

@ -1,47 +0,0 @@
package controller;
import javafx.animation.Animation;
import javafx.animation.KeyFrame;
import javafx.animation.Timeline;
import javafx.animation.Transition;
import javafx.event.ActionEvent;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.util.Duration;
import model.Avatar;
import model.Case;
import model.Map;
import java.net.URL;
import java.util.ResourceBundle;
public class PageGameController implements Initializable {
@FXML
private ImageView map;
@FXML
private Button boutonDe;
@FXML
private ImageView persoImageView;
PersoController persoController;
Case caseActuelle;
MapController mapController;
Case caseAncienne;
String pathPerso;
Image imagePerso;
@Override
public void initialize(URL url, ResourceBundle resourceBundle) {
}
public void lancerDe(ActionEvent actionEvent) throws InterruptedException {
System.out.println("lancer de");
}
}

@ -17,6 +17,12 @@ public class PersoController {
private Case actualCase; private Case actualCase;
private Case oldCase; private Case oldCase;
/**
* Method to create the avatar
* @param difficulty
* @param perso
* @param map
*/
public void createAvatar(int difficulty, int perso, Map map) { public void createAvatar(int difficulty, int perso, Map map) {
switch (perso) { switch (perso) {
case 1: case 1:
@ -33,6 +39,13 @@ public class PersoController {
} }
} }
/**
* Method to initialize the avatar
* @param difficulty
* @param perso
* @param map
* @return the image of the avatar
*/
public AnchorPane playerInitialisation(int difficulty, int perso, Map map) { public AnchorPane playerInitialisation(int difficulty, int perso, Map map) {
createAvatar(difficulty, perso, map); createAvatar(difficulty, perso, map);
@ -49,23 +62,43 @@ public class PersoController {
return test; return test;
} }
/**
* Method to get the path of the image
* @return the path of the image
*/
public String getPath(){ public String getPath(){
return avatar.getImage(); return avatar.getImage();
} }
/**
* Method to get the X coordinate of the avatar
* @return the X coordinate of the avatar
*/
public int getX(){ public int getX(){
return avatar.getCoordX(); return avatar.getCoordX();
} }
/**
* Method to get the Y coordinate of the avatar
* @return the Y coordinate of the avatar
*/
public int getY(){ public int getY(){
return avatar.getCoordY(); return avatar.getCoordY();
} }
/**
* Method to set the actual case of the avatar
* @param actual
*/
public void setActualCase(Case actual){ public void setActualCase(Case actual){
this.actualCase = actual; this.actualCase = actual;
} }
/**
* Method to get the actual case of the avatar
* @return
*/
public Case getActualCase() { public Case getActualCase() {
return this.actualCase; return this.actualCase;
} }
@ -74,6 +107,10 @@ public class PersoController {
return this.oldCase; return this.oldCase;
} }
/**
* Method to set the old case of the avatar
* @param old
*/
public void setOldCase(Case old){ public void setOldCase(Case old){
this.oldCase = old; this.oldCase = old;
} }

@ -37,11 +37,20 @@ public class TopPlayerController implements Initializable {
private Text resultat9; private Text resultat9;
private Text resultat10; private Text resultat10;
/**
* Initializes the controller class.
* @param url
* @param resourceBundle
*/
@Override @Override
public void initialize(URL url, ResourceBundle resourceBundle) { public void initialize(URL url, ResourceBundle resourceBundle) {
initialisationTexte(); initialisationTexte();
afficherRésultat(); afficherRésultat();
} }
/**
* Method to initialize the text
*/
public void initialisationTexte(){ public void initialisationTexte(){
resultat1 = new Text(); resultat1 = new Text();
resultat1.setText(""); resultat1.setText("");
@ -108,6 +117,9 @@ public class TopPlayerController implements Initializable {
levelRoot.getChildren().addAll(resultat1,resultat2,resultat3,resultat4,resultat5,resultat6,resultat7,resultat8,resultat9,resultat10); levelRoot.getChildren().addAll(resultat1,resultat2,resultat3,resultat4,resultat5,resultat6,resultat7,resultat8,resultat9,resultat10);
} }
/**
* Method to display the result
*/
public void afficherRésultat(){ public void afficherRésultat(){
ResultatTxt resultatTxt = new ResultatTxt(); ResultatTxt resultatTxt = new ResultatTxt();
ListeScore listeScore = new ListeScore(); ListeScore listeScore = new ListeScore();
@ -376,6 +388,11 @@ public class TopPlayerController implements Initializable {
} }
} }
/**
* Méthod to return to the menu
* @param event
* @throws Exception
*/
@FXML @FXML
void returnToMenu(MouseEvent event) throws Exception{ void returnToMenu(MouseEvent event) throws Exception{
AnchorPane pane = FXMLLoader.load(Objects.requireNonNull(getClass().getResource("/fxml/MainPage.fxml"))); AnchorPane pane = FXMLLoader.load(Objects.requireNonNull(getClass().getResource("/fxml/MainPage.fxml")));

@ -7,6 +7,7 @@ import javafx.scene.Scene;
import javafx.stage.Stage; import javafx.stage.Stage;
import model.*; import model.*;
import java.io.*;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Objects; import java.util.Objects;
@ -14,6 +15,11 @@ public class Main extends Application {
private Album song; private Album song;
/**
* Method which is called when the application is launched
* @param primaryStage
* @throws Exception
*/
@Override @Override
public void start(Stage primaryStage) throws Exception { public void start(Stage primaryStage) throws Exception {
@ -37,14 +43,19 @@ public class Main extends Application {
song.play(); song.play();
} }
/**
* Method to stop the music
*/
@Override @Override
public void stop(){ public void stop(){
System.out.println("Stopping");
song.stop(); song.stop();
} }
/**
* Constructor of the Main class
* @param args
*/
public static void main(String[] args) { public static void main(String[] args) {
launch(args); launch(args);
} }

@ -12,10 +12,17 @@ public class Album {
private ArrayList<Musique> listeMusiques; private ArrayList<Musique> listeMusiques;
private Thread musicThread; private Thread musicThread;
/**
* Constructor for the Album class
* @param listeMusiques
*/
public Album(ArrayList<Musique> listeMusiques) { public Album(ArrayList<Musique> listeMusiques) {
this.listeMusiques = listeMusiques; this.listeMusiques = listeMusiques;
} }
/**
* Method that plays the music
*/
public void play(){ public void play(){
musicThread = new Thread("musique") { musicThread = new Thread("musique") {
@ -27,7 +34,7 @@ public class Album {
for (Musique musique : listeMusiques) { for (Musique musique : listeMusiques) {
media = new Media(Objects.requireNonNull(getClass().getResource(musique.getPath())).toExternalForm()); media = new Media(Objects.requireNonNull(getClass().getResource(musique.getPath())).toExternalForm());
mediaPlayer = new AudioClip(media.getSource()); mediaPlayer = new AudioClip(media.getSource());
mediaPlayer.volumeProperty().setValue(0); mediaPlayer.volumeProperty().setValue(0.025);
mediaPlayer.play(); mediaPlayer.play();
try { try {
Thread.sleep(musique.getTemps()); Thread.sleep(musique.getTemps());
@ -42,18 +49,34 @@ public class Album {
} }
/**
* Method that stops the music
*/
public void stop() { public void stop() {
musicThread.stop(); musicThread.stop();
} }
/**
* Method that add a music to the list
* @param musique
*/
public void addList(Musique musique){ public void addList(Musique musique){
listeMusiques.add(musique); listeMusiques.add(musique);
} }
/**
* Method that remove a music from the list
* @param musique
*/
public void removeList(Musique musique){ public void removeList(Musique musique){
listeMusiques.remove(musique); listeMusiques.remove(musique);
} }
/**
* Method that return the list of music
* @return listeMusiques
*/
public List<Musique> getListeMusiques() { public List<Musique> getListeMusiques() {
return listeMusiques; return listeMusiques;
} }

@ -6,6 +6,13 @@ public class Avatar {
private int coordX; private int coordX;
private int coordY; private int coordY;
/**
* Constructor for the Avatar class
* @param idAvatar
* @param image
* @param coordX
* @param coordY
*/
public Avatar(int idAvatar, String image, int coordX, int coordY) { public Avatar(int idAvatar, String image, int coordX, int coordY) {
this.idAvatar = idAvatar; this.idAvatar = idAvatar;
this.image = image; this.image = image;
@ -13,43 +20,75 @@ public class Avatar {
this.coordY = coordY; this.coordY = coordY;
} }
public Avatar(int idAvatar, String image) { /**
this.idAvatar = idAvatar; * Method to get the ID of the avatar
this.image = image; * @return idAvatar
} */
public int getIdAvatar() { public int getIdAvatar() {
return idAvatar; return idAvatar;
} }
/**
* Method to get the image of the avatar
* @return image
*/
public String getImage() { public String getImage() {
return this.image; return this.image;
} }
/**
* Method to get the X coordinate of the avatar
* @return coordX
*/
public int getCoordX() { public int getCoordX() {
return coordX; return coordX;
} }
/**
* Method to get the Y coordinate of the avatar
* @return coordY
*/
public int getCoordY() { public int getCoordY() {
return coordY; return coordY;
} }
/**
* Method to set the ID of the avatar
* @param idAvatar
*/
public void setIdAvatar(int idAvatar) { public void setIdAvatar(int idAvatar) {
this.idAvatar = idAvatar; this.idAvatar = idAvatar;
} }
/**
* Method to set the image of the avatar
* @param image
*/
public void setImage(String image) { public void setImage(String image) {
this.image = image; this.image = image;
} }
/**
* Method to set the X coordinate of the avatar
* @param coordX
*/
public void setCoordX(int coordX) { public void setCoordX(int coordX) {
this.coordX = coordX; this.coordX = coordX;
} }
/**
* Method to set the Y coordinate of the avatar
* @param coordY
*/
public void setCoordY(int coordY) { public void setCoordY(int coordY) {
this.coordY = coordY; this.coordY = coordY;
} }
/**
* Method to get the coordinates of the avatar
* @param coordX
* @param coordY
*/
public void setCoord(int coordX, int coordY){ public void setCoord(int coordX, int coordY){
this.coordX = coordX; this.coordX = coordX;
this.coordY = coordY; this.coordY = coordY;

@ -8,6 +8,11 @@ public enum Bonus {
MOVE_FORWARD_8, MOVE_FORWARD_8,
NEW_DICE; NEW_DICE;
/**
* Method that returns the bonus associated to the given string.
* @return the bonus associated to the given string.
*/
public static Bonus randomGet(){ public static Bonus randomGet(){
int i = (int) (Math.random() * 8); int i = (int) (Math.random() * 8);
switch (i) { switch (i) {

@ -10,6 +10,17 @@ public class Case {
boolean isBonus; boolean isBonus;
int sizeTile; int sizeTile;
/**
* Constructor of the Case class
* @param idCase
* @param coordX
* @param coordY
* @param isStart
* @param isBonus
* @param isMalus
* @param isEnd
* @param map
*/
public Case(int idCase, int coordX, int coordY, boolean isStart, boolean isBonus, boolean isMalus, boolean isEnd, Map map) { public Case(int idCase, int coordX, int coordY, boolean isStart, boolean isBonus, boolean isMalus, boolean isEnd, Map map) {
this.sizeTile = map.getSizeTile(); this.sizeTile = map.getSizeTile();
this.idCase = idCase; this.idCase = idCase;
@ -21,50 +32,98 @@ public class Case {
this.isEnd = isEnd; this.isEnd = isEnd;
} }
/**
*Method to get the id of the case
* @return idCase
*/
public int getIdCase() { public int getIdCase() {
return idCase; return idCase;
} }
/**
* Method to set the X coordinate of the case
* @return coordX
*/
public int getCoordX() { public int getCoordX() {
return coordX; return coordX;
} }
/**
* Method to set the Y coordinate of the case
* @return coordY
*/
public int getCoordY() { public int getCoordY() {
return coordY; return coordY;
} }
/**
* Method to verify if the case is a start
* @return isStart
*/
public boolean isStart() { public boolean isStart() {
return isStart; return isStart;
} }
/**
* Method to verify if the case is an end
* @return isEnd
*/
public boolean isEnd() { public boolean isEnd() {
return isEnd; return isEnd;
} }
/**
* Method to verify if the case is a bonus
* @return isBonus
*/
public boolean isBonus() { public boolean isBonus() {
return isBonus; return isBonus;
} }
/**
* Method to verify if the case is a malus
* @return isMalus
*/
public boolean isMalus() { public boolean isMalus() {
return isMalus; return isMalus;
} }
/**
* Method to set the ID of the case
* @param idCase
*/
public void setIdCase(int idCase) { public void setIdCase(int idCase) {
this.idCase = idCase; this.idCase = idCase;
} }
/**
* Method to set the X coordinate of the case
* @param coordX
*/
public void setCoordX(int coordX) { public void setCoordX(int coordX) {
this.coordX = coordX; this.coordX = coordX;
} }
/**
* Method to set the Y coordinate of the case
* @param coordY
*/
public void setCoordY(int coordY) { public void setCoordY(int coordY) {
this.coordY = coordY; this.coordY = coordY;
} }
/**
* Method to set if the case is a start
* @param start
*/
public void setStart(boolean start) { public void setStart(boolean start) {
isStart = start; isStart = start;
} }
/**
* Method to set if the case is an end
* @param end
*/
public void setEnd(boolean end) { public void setEnd(boolean end) {
isEnd = end; isEnd = end;
} }

@ -6,6 +6,13 @@ public class Creature {
int coordX; int coordX;
int coordY; int coordY;
/**
* Constructor of Creature class
* @param idCreature
* @param image
* @param coordX
* @param coordY
*/
public Creature(int idCreature, String image, int coordX, int coordY) { public Creature(int idCreature, String image, int coordX, int coordY) {
this.idCreature = idCreature; this.idCreature = idCreature;
this.image = image; this.image = image;
@ -13,26 +20,50 @@ public class Creature {
this.coordY = coordY; this.coordY = coordY;
} }
/**
* Method to get the id of the creature
* @return idCreature
*/
public int getIdCreature() { public int getIdCreature() {
return idCreature; return idCreature;
} }
/**
* Method to get the image of the creature
* @return image
*/
public String getImage() { public String getImage() {
return image; return image;
} }
/**
* Method to get the x coordinate of the creature
* @return coordX
*/
public int getCoordX() { public int getCoordX() {
return coordX; return coordX;
} }
/**
* Method to get the y coordinate of the creature
* @return coordY
*/
public int getCoordY() { public int getCoordY() {
return coordY; return coordY;
} }
/**
* Method to set the x coordinate of the creature
* @param coordX
*/
public void setCoordX(int coordX) { public void setCoordX(int coordX) {
this.coordX = coordX; this.coordX = coordX;
} }
/**
* Method to set the y coordinate of the creature
* @param coordY
*/
public void setCoordY(int coordY) { public void setCoordY(int coordY) {
this.coordY = coordY; this.coordY = coordY;
} }

@ -13,12 +13,21 @@ public class GameLoop {
private CreatureController c; private CreatureController c;
@FXML public ImageView creatureImageView; @FXML public ImageView creatureImageView;
/**
* Constructor for GameLoop class
* @param lv
* @param map
* @param creatureImageView
*/
public GameLoop(int lv, Map map, ImageView creatureImageView){ public GameLoop(int lv, Map map, ImageView creatureImageView){
this.lv = lv; this.lv = lv;
this.map = map; this.map = map;
this.creatureImageView = creatureImageView; this.creatureImageView = creatureImageView;
} }
/**
* Method to start the game loop
*/
public void start() { public void start() {
c = new CreatureController(lv,map, creatureImageView); c = new CreatureController(lv,map, creatureImageView);
timer = new Thread("timer") { timer = new Thread("timer") {
@ -57,6 +66,9 @@ public class GameLoop {
timer.start(); timer.start();
} }
/**
* Method to stop the game loop
*/
public void stop() { public void stop() {
System.out.println("GameLoop.stop()"); System.out.println("GameLoop.stop()");
timer.stop(); timer.stop();

@ -9,6 +9,10 @@ public class GameTime {
private Thread timer; private Thread timer;
private Text textTimer; private Text textTimer;
/**
* Constructor for GameTime class
* @param textTimer
*/
public GameTime(Text textTimer) { public GameTime(Text textTimer) {
this.textTimer = textTimer; this.textTimer = textTimer;
} }
@ -32,10 +36,18 @@ public class GameTime {
timer.start(); timer.start();
} }
/**
* Method to stop the timer
*/
public void stop() { public void stop() {
System.out.println("GameTime.stop()"); System.out.println("GameTime.stop()");
timer.stop(); timer.stop();
} }
/**
* Method to get the time
* @return time
*/
public int getTime() { public int getTime() {
return Integer.parseInt(textTimer.getText()); return Integer.parseInt(textTimer.getText());
} }

@ -6,12 +6,18 @@ import java.util.ArrayList;
public class ListeScore { public class ListeScore {
private ArrayList listeScore = new ArrayList<Score>(); private ArrayList listeScore = new ArrayList<Score>();
public ListeScore() { /**
} * Method to add a score to the list of scores
* @param score
*/
public void addScore(Score score) { public void addScore(Score score) {
listeScore.add(score); listeScore.add(score);
} }
/**
* Method to get the list of scores
* @return
*/
public ArrayList getListeScore() { public ArrayList getListeScore() {
return listeScore; return listeScore;
} }

@ -7,6 +7,10 @@ public enum Malus {
MOVE_BACKWARD_5, // Recule de 5 MOVE_BACKWARD_5, // Recule de 5
LAST_POSITION; // Retour a la position initiale LAST_POSITION; // Retour a la position initiale
/**
* Method to get the malus
* @return the malus
*/
public static Malus randomGet(){ public static Malus randomGet(){
int i = (int) (Math.random() * 8); int i = (int) (Math.random() * 8);
switch (i) { switch (i) {

@ -9,6 +9,11 @@ public class Map {
private int coordStartX; private int coordStartX;
private int coordStartY; private int coordStartY;
/**
* Constructor of the Map class
* @param sizeTile
* @param sizeMap
*/
public Map(int sizeTile, int sizeMap) { public Map(int sizeTile, int sizeMap) {
this.sizeTile = sizeTile; this.sizeTile = sizeTile;
this.sizeMap = sizeMap; this.sizeMap = sizeMap;
@ -17,6 +22,10 @@ public class Map {
this.coordStartY = getCoordStartY(); this.coordStartY = getCoordStartY();
} }
/**
* Method to add a case to the map
* @param c
*/
public void addCase(Case c) { public void addCase(Case c) {
this.map.add(c); this.map.add(c);
if(c.isStart){ if(c.isStart){
@ -24,31 +33,76 @@ public class Map {
setCoordStartY(c.coordY); setCoordStartY(c.coordY);
} }
} }
/**
* Method to remove a case from the map
* @param c
*/
public void removeCase(Case c) { public void removeCase(Case c) {
this.map.remove(c); this.map.remove(c);
} }
/**
* Method to get the map
* @return map
*/
public ArrayList<Case> getMap() { public ArrayList<Case> getMap() {
return this.map; return this.map;
} }
/**
* Method to get the size of the tile
* @return sizeTile
*/
public int getSizeTile() { public int getSizeTile() {
return this.sizeTile; return this.sizeTile;
} }
/**
* Method to get the size of the map
* @return sizeMap
*/
public int getSizeMap() { public int getSizeMap() {
return this.sizeMap; return this.sizeMap;
} }
/**
* Method to get the X coordonate of the start case
* @return coordStartX
*/
public int getCoordStartX(){ public int getCoordStartX(){
return coordStartX; return coordStartX;
} }
/**
* Method to set the X coordonate of the start case
* @param x
*/
public void setCoordStartX(int x){ public void setCoordStartX(int x){
this.coordStartX = x; this.coordStartX = x;
} }
/**
* Method to get the Y coordonate of the start case
* @return coordStartY
*/
public int getCoordStartY(){ public int getCoordStartY(){
return coordStartY; return coordStartY;
} }
/**
* Method to set the Y coordonate of the start case
* @param y
*/
public void setCoordStartY(int y){ public void setCoordStartY(int y){
this.coordStartY = y; this.coordStartY = y;
} }
/**
* Method to get the next case of the map
* @param c
* @return Case
*/
public Case getNextCase(Case c){ public Case getNextCase(Case c){
int i,j; int i,j;
for(i = 0; i < this.map.size(); i++){ for(i = 0; i < this.map.size(); i++){
@ -65,7 +119,12 @@ public class Map {
return c; return c;
} }
/**
* Method to get the case which is num case after the current case
* @param c
* @param num
* @return Case
*/
public Case getCase(Case c, int num){ public Case getCase(Case c, int num){
int j,i = 0; int j,i = 0;
for(Case cases : this.map){ for(Case cases : this.map){
@ -82,6 +141,10 @@ public class Map {
return c; return c;
} }
/**
* Method to get the start case of the map
* @return
*/
public Case getStartCase(){ public Case getStartCase(){
for(Case c : this.map){ for(Case c : this.map){
if(c.isStart){ if(c.isStart){

@ -9,6 +9,11 @@ public class MapCreature {
private int coordStartX; private int coordStartX;
private int coordStartY; private int coordStartY;
/**
* Constructor of MapCreature class
* @param sizeTile
* @param sizeMap
*/
public MapCreature(int sizeTile, int sizeMap) { public MapCreature(int sizeTile, int sizeMap) {
this.coordStartX = getCoordStartX(); this.coordStartX = getCoordStartX();
this.coordStartY = getCoordStartY(); this.coordStartY = getCoordStartY();
@ -16,6 +21,10 @@ public class MapCreature {
this.sizeMap = sizeMap; this.sizeMap = sizeMap;
} }
/**
* Method to add a case to the map
* @param c
*/
public void addCase(Case c) { public void addCase(Case c) {
this.map.add(c); this.map.add(c);
if(c.isStart){ if(c.isStart){
@ -23,31 +32,76 @@ public class MapCreature {
setCoordStartY(c.coordY); setCoordStartY(c.coordY);
} }
} }
/**
* Method to remove a case from the map
* @param c
*/
public void removeCase(Case c) { public void removeCase(Case c) {
this.map.remove(c); this.map.remove(c);
} }
/**
* Method to get the map
* @return map
*/
public ArrayList<Case> getMap() { public ArrayList<Case> getMap() {
return this.map; return this.map;
} }
/**
* Method to get the size of the tile
* @return sizeTile
*/
public int getSizeTile() { public int getSizeTile() {
return this.sizeTile; return this.sizeTile;
} }
/**
* Method to get the size of the map
* @return sizeMap
*/
public int getSizeMap() { public int getSizeMap() {
return this.sizeMap; return this.sizeMap;
} }
/**
* Method to get the X coordinate of the start case
* @return coordStartX
*/
public int getCoordStartX(){ public int getCoordStartX(){
return coordStartX; return coordStartX;
} }
/**
* Method to set the X coordinate of the start case
* @param x
*/
public void setCoordStartX(int x){ public void setCoordStartX(int x){
this.coordStartX = x; this.coordStartX = x;
} }
/**
* Method to get the Y coordinate of the start case
* @return coordStartY
*/
public int getCoordStartY(){ public int getCoordStartY(){
return coordStartY; return coordStartY;
} }
/**
* Method to set the Y coordinate of the start case
* @param y
*/
public void setCoordStartY(int y){ public void setCoordStartY(int y){
this.coordStartY = y; this.coordStartY = y;
} }
/**
* Method to get the next case of the map
* @param c
* @return nextCase
*/
public Case getNextCase(Case c){ public Case getNextCase(Case c){
int i; int i;
int j; int j;
@ -60,6 +114,10 @@ public class MapCreature {
return c; return c;
} }
/**
* Method to get the start case of the map
* @return startCase
*/
public Case getStartCase(){ public Case getStartCase(){
for(Case c : this.map){ for(Case c : this.map){
if(c.isStart){ if(c.isStart){

@ -11,15 +11,28 @@ public class Musique {
private String path; private String path;
private int temps; private int temps;
/**
* Constructor of the Musique class
* @param path
* @param temps
*/
public Musique(String path , int temps) { public Musique(String path , int temps) {
this.path = path; this.path = path;
this.temps = temps; this.temps = temps;
} }
/**
* Method to get the path of the music
* @return path
*/
public String getPath() { public String getPath() {
return path; return path;
} }
/**
* Method to get the time of the music
* @return temps
*/
public int getTemps() { public int getTemps() {
return temps; return temps;
} }

@ -10,7 +10,11 @@ import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
public class ResultatTxt { public class ResultatTxt {
/**
* Method to save the score in the txt file
* @param resultat
* @param lvl
*/
public void sauvegarderResultat(int resultat, int lvl) { public void sauvegarderResultat(int resultat, int lvl) {
try { try {
LocalDate today = LocalDate.now(); LocalDate today = LocalDate.now();
@ -22,15 +26,16 @@ public class ResultatTxt {
} }
} }
/**
* Method to load the score in the txt file
* @return ListeScore
*/
public ListeScore chargerResultat(){ public ListeScore chargerResultat(){
ListeScore ls = new ListeScore(); ListeScore ls = new ListeScore();
try try
{ {
// Le fichier d'entrée
File file = new File("ressources/resultat/resultats.txt"); File file = new File("ressources/resultat/resultats.txt");
// Créer l'objet File Reader
FileReader fr = new FileReader(file); FileReader fr = new FileReader(file);
// Créer l'objet BufferedReader
BufferedReader br = new BufferedReader(fr); BufferedReader br = new BufferedReader(fr);
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
String line; String line;
@ -41,21 +46,14 @@ public class ResultatTxt {
String date; String date;
while((line = br.readLine()) != null) while((line = br.readLine()) != null)
{ {
// ajoute la ligne au buffer
tab = line.split(separateur); tab = line.split(separateur);
level = Integer.parseInt(tab[1]); level = Integer.parseInt(tab[1]);
resultat = Integer.parseInt(tab[0]); resultat = Integer.parseInt(tab[0]);
date = tab[2]; date = tab[2];
Score sc = new Score(resultat, level, date); Score sc = new Score(resultat, level, date);
ls.addScore(sc); ls.addScore(sc);
sb.append(resultat);
sb.append(level);
sb.append(date);
} }
fr.close(); fr.close();
System.out.println("Contenu du fichier: ");
System.out.println(sb.toString());
} }
catch(IOException e) catch(IOException e)
{ {
@ -63,41 +61,4 @@ public class ResultatTxt {
} }
return ls; return ls;
} }
/*public ListeScore chargerResultat() {
ListeScore lp = new ListeScore();
String[] tab;
InputStream flux;
int level;
int resultat;
String date;
try {
File fi =new File("resultats.txt");
if(!fi.exists()) {
flux = getClass().getClassLoader().getResourceAsStream("Resultats/resultats");
assert flux != null;
}
else {
flux = new FileInputStream(fi);
}
InputStreamReader lecture = new InputStreamReader(flux);
BufferedReader in = new BufferedReader(lecture);
String ligne;
String separateur = " ";
while ((ligne = in.readLine()) != null) {
tab = ligne.split(separateur);
level = Integer.parseInt(tab[1]);
resultat = Integer.parseInt(tab[0]);
date = tab[2];
Score sc = new Score(resultat, level, date);
lp.addScore(sc);
}
in.close();
} catch (IOException e) {
e.printStackTrace();
}
return lp;
}*/
} }

@ -7,19 +7,38 @@ public class Score {
private int level; private int level;
private String date; private String date;
/**
* Constructor for Score class
* @param score
* @param level
* @param date
*/
public Score(int score, int level,String date) { public Score(int score, int level,String date) {
this.score = score; this.score = score;
this.level = level; this.level = level;
this.date = date; this.date = date;
} }
/**
* Method to get the level
* @return level
*/
public int getLevel() { public int getLevel() {
return level; return level;
} }
/**
* Method to get the score
* @return score
*/
public int getScore() { public int getScore() {
return score; return score;
} }
/**
* Method to get the date
* @return date
*/
public String getDate() { public String getDate() {
return date; return date;
} }

@ -3,6 +3,9 @@ package model;
public class Time { public class Time {
private Thread timer; private Thread timer;
/**
* Method to start the timer
*/
public void start() { public void start() {
timer = new Thread("timer") { timer = new Thread("timer") {
public void run() { public void run() {

Loading…
Cancel
Save