rework: ajout plusieurs classes et modification logique

This commit is contained in:
2025-11-08 17:27:35 +01:00
parent e32805bcd6
commit 09302dd880
8 changed files with 256 additions and 139 deletions

View File

@@ -5,7 +5,7 @@ import java.util.Random;
* Chaque appel à {@link #makeMove()} avance la voiture d'une position.
* Quand la position atteint la fin de la boucle, un nouveau tour est compté.
*/
public class Car implements GObserver
public class Car
{
/** Ajout de la classe Random (Evite de le recreer a chaque fois) */
private Random rand = new Random();
@@ -97,8 +97,7 @@ public class Car implements GObserver
return this;
}
@Override
public boolean apply()
public void run()
{
if (this.fuel > 0)
{
@@ -106,8 +105,6 @@ public class Car implements GObserver
int random = rand.nextInt(interval[0], interval[1]);
makeMove(random).consumeFuel();
}
return true;
}
public int getPos()