created Method initphase in Game.java
This commit is contained in:
		
							parent
							
								
									d6a46f3cae
								
							
						
					
					
						commit
						4ebe8cb1ed
					
				| 
						 | 
				
			
			@ -2,6 +2,8 @@ package ch.zhaw.pm2.racetrack;
 | 
			
		|||
 | 
			
		||||
import ch.zhaw.pm2.racetrack.given.GameSpecification;
 | 
			
		||||
 | 
			
		||||
import java.io.File;
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import static ch.zhaw.pm2.racetrack.PositionVector.Direction;
 | 
			
		||||
| 
						 | 
				
			
			@ -14,6 +16,22 @@ import static ch.zhaw.pm2.racetrack.PositionVector.Direction;
 | 
			
		|||
public class Game implements GameSpecification {
 | 
			
		||||
    public static final int NO_WINNER = -1;
 | 
			
		||||
 | 
			
		||||
    UserInterface userInterface;
 | 
			
		||||
 | 
			
		||||
    public Game(String welcometext) {
 | 
			
		||||
        userInterface = new UserInterface(welcometext);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void initphase() {
 | 
			
		||||
        File folder = new File("your/path");
 | 
			
		||||
        File[] listOfFiles = folder.listFiles();
 | 
			
		||||
        List<String> tracks = new ArrayList<>();
 | 
			
		||||
        for(File file : listOfFiles){
 | 
			
		||||
            tracks.add(file.getName());
 | 
			
		||||
        }
 | 
			
		||||
        userInterface.selectOption("Select Track file", tracks);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Return the index of the current active car.
 | 
			
		||||
     * Car indexes are zero-based, so the first car is 0, and the last car is getCarCount() - 1.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue