From 5bbca6047d11dc031582e155c9af211ac7420041 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20GUEZO?= Date: Fri, 7 Nov 2025 18:13:50 +0100 Subject: [PATCH] feat: ajout getters --- src/Car.java | 5 +++++ src/Game.java | 3 ++- src/Main.java | 26 ++------------------------ src/Map.java | 16 ++++++++++++++++ 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/Car.java b/src/Car.java index 1ac630f..9e4ea1c 100644 --- a/src/Car.java +++ b/src/Car.java @@ -109,4 +109,9 @@ public class Car implements GObserver return true; } + + public int getPos() + { + return pos; + } } \ No newline at end of file diff --git a/src/Game.java b/src/Game.java index c5ef574..b37b047 100644 --- a/src/Game.java +++ b/src/Game.java @@ -7,6 +7,7 @@ public class Game private Map map; private ArrayList obs; + private final int time = 1000; public static class Builder { @@ -122,7 +123,7 @@ public class Game try { step(); - Thread.sleep(1000); + Thread.sleep(time); } catch (InterruptedException e) { e.printStackTrace(); } diff --git a/src/Main.java b/src/Main.java index 1b034ad..597e3c0 100644 --- a/src/Main.java +++ b/src/Main.java @@ -1,33 +1,11 @@ public class Main { - public static void main(String[] args) throws InterruptedException { - // Map m = Map.fromChars(new Character[][] { - // {'3', '#', '2'}, - // {'#', ' ', 'S'}, - // {'9', '#', 'F'}, - // }); - + public static void main(String[] args) throws InterruptedException + { Game game = new Game.Builder() .defaultMap() .setPlayers(3) .build(); - - Thread t = new Thread(() -> { - int i = 0; - while (i++ < 10) - { - try - { - Thread.sleep(5000); - } - catch (InterruptedException e) - { - e.printStackTrace(); - } - System.out.println(game.togglePause() ? "stop" : "fini" ); - } - }); - t.start(); game.run(); } } \ No newline at end of file diff --git a/src/Map.java b/src/Map.java index fb0812f..e2ad541 100644 --- a/src/Map.java +++ b/src/Map.java @@ -22,6 +22,8 @@ public class Map */ private ArrayList pathMap; + private int width, height; + /** * Crée une nouvelle instance de Map à partir d'un tableau générique * et d'une fonction de transformation. @@ -108,6 +110,10 @@ public class Map private Map(Circuit[][] map) { this.map = map; + + this.width = map[0].length; + this.height = map.length; + boolean isPossible = this.buildPath(); if (!isPossible) @@ -280,4 +286,14 @@ public class Map { return this.pathMap.size(); } + + public int getWidth() + { + return this.width; + } + + public int getHeight() + { + return this.height; + } }