changes in Methods in Game.java

created MainClass.java
This commit is contained in:
romanschenk37 2022-03-11 12:08:17 +01:00
parent 7e5d349f3f
commit af6914f795
2 changed files with 22 additions and 3 deletions

View File

@ -122,7 +122,7 @@ public class Game implements GameSpecification {
@Override @Override
public int getWinner() { public int getWinner() {
// TODO: implementation // TODO: implementation
throw new UnsupportedOperationException(); return NO_WINNER;
} }
/** /**
@ -168,14 +168,16 @@ public class Game implements GameSpecification {
track.carDoesCrash(currentCarIndex, crashPosition); track.carDoesCrash(currentCarIndex, crashPosition);
} }
else { else {
track.getCar(currentCarIndex).move(); track.moveCar(currentCarIndex);
} }
} }
public void gamePhase() { public void gamePhase() {
do{ do{
userInterface.printTrack(track); userInterface.printTrack(track);
doCarTurn(userInterface.selectDirection(currentCarIndex, track.getCarId(currentCarIndex))); track.getCar(currentCarIndex).getMoveStrategy(); //TODO Movestrategy berücksichtigen ??
Direction direction = userInterface.selectDirection(currentCarIndex, track.getCarId(currentCarIndex));
doCarTurn(direction);
if(getWinner() != NO_WINNER) { if(getWinner() != NO_WINNER) {
return; return;
} }

View File

@ -0,0 +1,17 @@
package ch.zhaw.pm2.racetrack;
import java.io.FileNotFoundException;
public class Main {
public static void main(String[] args) throws InvalidTrackFormatException, FileNotFoundException {
UserInterface userInterface = new UserInterface("Hello and Welcome");
Game game = new Game(userInterface);
if(game.initPhase()){
game.gamePhase();
int winner = game.getWinner();
}
}
}