The following program draws an BB-8 as shown below.  Modify the program to move the BB-8 left or right using the arrow keys.  The program can be download

The following program draws an BB-8 as shown below.  Modify the program to move the BB-8 left or right using the arrow keys.  The program can be download from the CMS. Please use Javafx 

import javafx.application.Application;

import javafx.scene.Scene;

import javafx.scene.input.KeyCode;

import javafx.scene.layout.Pane;

import javafx.scene.paint.Color;

import javafx.scene.shape.Circle;

import javafx.scene.shape.Line;

import javafx.stage.Stage;

public class MovingBB8 extends Application {

     @Override // Override the start method in the Application class

public void start(Stage primaryStage) { 

           BB8Pane pane = new BB8Pane();

           pane.setOnKeyPressed(e -> { 

               // Write code here

           });

           // Create  scene and place it in the stage

           Scene scene = new Scene(pane, 400, 120);

           primaryStage.setTitle(“MovingBB8”);

           primaryStage.setScene(scene);

           primaryStage.show();

           pane.requestFocus();

     }

class BB8Pane extends Pane {

private Circle circle1 = new Circle(200, 50, 15);

private Circle circle2 = new Circle(200, 70, 20);

private Line line = new Line(200, 25, 200, 35);

public BB8Pane() {

           line.setStroke(Color.BLACK);

           circle1.setFill(Color.CORAL);

           circle2.setFill(Color.CORAL);

           getChildren().addAll(circle1, circle2, line);

     }

public void moveLeft() {

           // Write  code here

     }

public void moveRight() {

     // write  code here

     }

}

Share This Post

Email
WhatsApp
Facebook
Twitter
LinkedIn
Pinterest
Reddit

Order a Similar Paper and get 15% Discount on your First Order

Related Questions

How does Rupa Huq’s argument in “Rethinking Subculture” relate to Dick Hebdige’s understanding of subculture, as explained by Huq? Explain how Hebdige or

How does Rupa Huq’s argument in “Rethinking Subculture” relate to Dick Hebdige’s understanding of subculture, as explained by Huq? Explain how Hebdige or Huq’s understanding of style relates to how youth express identity and community today. Normal 0 false false false EN-US X-NONE X-NONE /* Style Definitions */ table.MsoNormalTable {mso-style-name:”Table

Week8_Test Plan Instructions: The Test Plan for each project includes the Pseudocode, Flowchart, Goals and Objectives, Functional Requirements, and Test

Week8_Test Plan Instructions: The Test Plan for each project includes the Pseudocode, Flowchart, Goals and Objectives, Functional Requirements, and Test Matrix including Actual Output column.  Below the table are screenshots verifying the actual output for each case. Note:  Your programming projects should be submitted in the Revel environment for grading. Week