fusion branch 'model/Car' dans model/Map

This commit is contained in:
2025-10-30 17:14:40 +01:00
2 changed files with 52 additions and 0 deletions

View File

@@ -13,6 +13,8 @@ public class Car {
/** Nombre total de cases dans une boucle (doit être > 0) */ /** Nombre total de cases dans une boucle (doit être > 0) */
private final int loop; private final int loop;
/** Nombre de fuel restant */
private int fuel = 60;
/** /**
* Construit une nouvelle voiture. * Construit une nouvelle voiture.
@@ -73,4 +75,15 @@ public class Car {
{ {
return loop; return loop;
} }
public int getFuel()
{
return fuel;
}
public Car consumeFuel()
{
fuel -= State.get().getConsumption();
return this;
}
} }

39
src/State.java Normal file
View File

@@ -0,0 +1,39 @@
public class State
{
public static enum DriveMode
{
// <CARBURANT PERDU> <PREMIER INTERVAL> <SECOND INTERVAL>
NORMAL(2, 1, 6);
private int carbUsed;
private int[] interval;
private DriveMode(int carbUsed, int fInterval, int sInterval)
{
this.carbUsed = carbUsed;
interval = new int[] {fInterval, sInterval};
}
public int getConsumption()
{
return carbUsed;
}
public int[] getInterval()
{
return interval;
}
}
private static DriveMode current = DriveMode.NORMAL;
public static DriveMode get()
{
return current;
}
public static void set(DriveMode DriveMode)
{
current = DriveMode;
}
}