From 63e6c68a461c9412b22a5f665ac7aac6d3a6acdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20GUEZO?= Date: Sun, 9 Nov 2025 15:00:18 +0100 Subject: [PATCH] feat(Car.java): ajout nom et couleur au modele --- src/Car.java | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Car.java b/src/Car.java index 0ffaf9c..1f381ba 100644 --- a/src/Car.java +++ b/src/Car.java @@ -13,7 +13,9 @@ public class Car /** Couleur de la voiture */ private Color color; - + /** Nom de la voiture */ + private String name; + /** Position actuelle dans la boucle (entre 0 et loop inclus) */ private int pos = 0; @@ -32,10 +34,11 @@ public class Car * @param loop nombre de positions par boucle (doit ĂȘtre > 0) * @throws IllegalArgumentException si {@code loop <= 0} */ - public Car(int loop, State state, Color color) + public Car(String name, Color color, int loop, State state) { - this.state = state; + this.name = name; this.color = color; + this.state = state; if (loop <= 0) throw new IllegalArgumentException("loop must be > 0!"); @@ -126,4 +129,10 @@ public class Car { this.color = color; } + + @Override + public String toString() + { + return this.name; + } } \ No newline at end of file