import java.util.ArrayList;

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.input.KeyCode;
import javafx.scene.layout.Pane;
import javafx.scene.shape.Line;
import javafx.stage.Stage;


public class Project3 extends Application{
	double startX = 200;
	double startY = 200;
	double endX = startX;
	double endY = startY;
	
	Line line = new Line(startX, startY, endX, endY);
	ArrayList line1 = new ArrayList();

	@Override
	public void start(Stage primaryStage) throws Exception {
		Pane pane = new Pane();
		
		pane.getChildren().add(line);
		
		pane.setOnKeyPressed(e -> {
			
			if(e.isShiftDown())
			{
				if (e.getCode() == KeyCode.UP){
					startY = line.getEndY();
					endY = line.getEndY() - 15;
				}
			    	 
			     
			    if (e.getCode() == KeyCode.DOWN){
			    	startY = line.getEndY();
			    	endY = line.getEndY() + 15;
			    }
			     
			    if (e.getCode() == KeyCode.RIGHT){ 
			    	startX = line.getEndX();
			    	endX = line.getEndX() +15;
			    }
			    	 
			    if (e.getCode() == KeyCode.LEFT){
			    	startX = line.getEndX();
			    	endX = line.getEndX()-15;
			    }
			    
			    line = new Line(startX, startY, endX, endY);
			    startX = endX;
			    startY = endY;
			    
			}
			else
			{
				if (e.getCode() == KeyCode.UP){
					startY = line.getEndY();
					endY = line.getEndY() - 15;
				}
			    	 
			     
			    if (e.getCode() == KeyCode.DOWN){
			    	startY = line.getEndY();
			    	endY = line.getEndY() + 15;
			    }
			     
			    if (e.getCode() == KeyCode.RIGHT){ 
			    	startX = line.getEndX();
			    	endX = line.getEndX() +15;
			    }
			    	 
			    if (e.getCode() == KeyCode.LEFT){
			    	startX = line.getEndX();
			    	endX = line.getEndX()-15;
			    }
			    
			    line = new Line(startX, startY, endX, endY);
			    pane.getChildren().add(line);
			    line1.add(line);
			    startX = endX;
			    startY = endY;
			}
			
			
			
		});
		
		Scene scene = new Scene(pane, 400, 400);
		primaryStage.setScene(scene);
		primaryStage.show();
		pane.requestFocus();
		
	}

	public static void main(String[] args) {
		launch(args);
	}
}