merge track into game and fix in initphase

This commit is contained in:
romanschenk37
2022-03-18 10:19:23 +01:00
parent 5ec7260b1e
commit a723ea16ec
4 changed files with 10 additions and 10 deletions
@@ -41,7 +41,7 @@ public class Game implements GameSpecification {
File selectedTrack = listOfFiles[userInterface.selectOption("Select Track file", tracks)];
try {
track = new Track(selectedTrack);
} catch (FileNotFoundException e) {
} catch (FileNotFoundException | PositionVectorNotValid e) {
e.printStackTrace();
}
List<String> moveStrategies = new ArrayList<>();
@@ -52,7 +52,7 @@ public class Game implements GameSpecification {
for(int i = 0; i < track.getCarCount() ; i++ ) {
int moveStrategie = userInterface.selectOption(
"Select Strategy for Car " + i + " (" + track.getCarId(i) + ")", moveStrategies);
switch (moveStrategie) { //TODO: set Movestrategy with method in Track
switch (moveStrategie + 1) { //TODO: set Movestrategy with method in Track
case 1:
track.getCar(i).setMoveStrategy(new DoNotMoveStrategy()); //TODO: add Arguments
break;
@@ -157,7 +157,7 @@ public class Game implements GameSpecification {
* for this turn
*/
@Override
public void doCarTurn(Direction acceleration) {
public void doCarTurn(Direction acceleration) throws PositionVectorNotValid {
// TODO: implementation
track.getCar(currentCarIndex).accelerate(acceleration);
@@ -178,7 +178,7 @@ public class Game implements GameSpecification {
}
}
public int gamePhase() {
public int gamePhase() throws PositionVectorNotValid {
do{
userInterface.printTrack(track);
Direction direction = track.getCar(currentCarIndex).getMoveStrategy().nextMove();
@@ -321,8 +321,8 @@ public class Game implements GameSpecification {
* @return A boolean indicator if the car would crash with a WALL or another car.
*/
@Override
public boolean willCarCrash(int carIndex, PositionVector position) {
return track.willCrashAtPosition(position); //TODO: add carIndex
public boolean willCarCrash(int carIndex, PositionVector position) throws PositionVectorNotValid {
return track.willCrashAtPosition(carIndex, position);
}
public boolean allCarsCrashed() {