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

Hello Students, As discussed in class, the Workspaces and Challenges are now active. Required Challenges for Full Credit To earn full credit (30% of the

Hello Students, As discussed in class, the Workspaces and Challenges are now active. Required Challenges for Full Credit To earn full credit (30% of the assignment), you must complete 8 challenges from the following list: Interns & HR on the Domain Controller Help Desk Fun: User Workstation Nightmares Dangerous Drives Preventative Protection: Thwarting the Imminent Threat Security

Please read the instructions below carefully. Required Challenges for Full Credit Vulnerability Scan Complete, Begin System Hardening [NG] Volatile

Please read the instructions below carefully. Required Challenges for Full Credit Vulnerability Scan Complete, Begin System Hardening [NG] Volatile Vulnerabilities [NG] The Network is Down! Internal Issues Edition [NG] The Network is Down! Contractor Edition [NG] (Complexity 1) The Network is Down! Contractor Edition [NG] Systems Security Analyst Crash Course

Hello Students, Please pay attention to the instructions below. Required Challenges for Full Credit To earn full credit (30% of the assignment), you must

Hello Students, Please pay attention to the instructions below. Required Challenges for Full Credit To earn full credit (30% of the assignment), you must complete 6 challenges from the following list: Interns & HR on the Domain Controller Help Desk Fun: User Workstation Nightmares Dangerous Drives Preventative Protection: Thwarting the Imminent Threat Security