mirror of
https://github.com/guezoloic/racing-game.git
synced 2026-03-28 18:03:50 +00:00
feat(Car.java): ajout nom et couleur au modele
This commit is contained in:
15
src/Car.java
15
src/Car.java
@@ -13,7 +13,9 @@ public class Car
|
|||||||
|
|
||||||
/** Couleur de la voiture */
|
/** Couleur de la voiture */
|
||||||
private Color color;
|
private Color color;
|
||||||
|
/** Nom de la voiture */
|
||||||
|
private String name;
|
||||||
|
|
||||||
/** Position actuelle dans la boucle (entre 0 et loop inclus) */
|
/** Position actuelle dans la boucle (entre 0 et loop inclus) */
|
||||||
private int pos = 0;
|
private int pos = 0;
|
||||||
|
|
||||||
@@ -32,10 +34,11 @@ public class Car
|
|||||||
* @param loop nombre de positions par boucle (doit être > 0)
|
* @param loop nombre de positions par boucle (doit être > 0)
|
||||||
* @throws IllegalArgumentException si {@code loop <= 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.color = color;
|
||||||
|
this.state = state;
|
||||||
|
|
||||||
if (loop <= 0)
|
if (loop <= 0)
|
||||||
throw new IllegalArgumentException("loop must be > 0!");
|
throw new IllegalArgumentException("loop must be > 0!");
|
||||||
@@ -126,4 +129,10 @@ public class Car
|
|||||||
{
|
{
|
||||||
this.color = color;
|
this.color = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return this.name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user