Transcribed TextTranscribed Text

Programming Requirements Document Lights for Good NARRATIVE DESCRIPTION This week we will review arrays, learn how to use audio clips, and practice JavaFX GUIs. You will create a new “Lights” game similar to the same device used by the Simon game. Ultimately, this could be a memory game to be used as therapy for stroke patients. If completed in its entirety, the first player would press 8 buttons on the game. This would “record” a sequence of colors. The second player (the stroke patient) would watch the first player and then try to remember the color sequence. They would attempt to replay the colors in the same order. You are going to program only a portion of the “game”. You will record the 8 colors selected by the first player in an integer array. Use the following values: • 0 represents red • 1 represents blue • 2 represents green • 3 represents yellow Create four GUI components that simulate the four buttons on the Simon hand-held game. We will call these the “color controls”. You can use Button GUI controls for the color controls (these are a simulation of the buttons on the Simon controller.) For example, below is one possible configuration for the color controls. You can set the background of buttons by using the setStyle() method of a Button object. For example, a button named redButton could have a red background by using: redButton.setStyle("-fx-background-color: #CC0000"); RBG triplets are used for the color where #CC0000 if a red variation. You can investigate other colors online at websites similar to: In addition to the color controls, create 3 additional buttons: 1. “New Game” button, 2. “Remember Game” button, and 3. “End Game” button. Add labels to the pane so that you can display instructions to the users of the game. Each time a color control is clicked, an audio clip will play (much like the Simon game). When the NEW GAME button is selected • Display a message telling the first player that they are to click 8 color buttons, one at a time. • As each button is clicked, Record the button color in the integer array. Remember: o 0 represents red o 1 represents blue o 2 represents green o 3 represents yellow • As each color is clicked, a short audio clip should play. Each color has its own audio clip. Samples are provided in Blackboard. Make sure one audio clip stops before the next plays. Refer to Section 7.7 in the Lewis textbook for an example of how to use an array of audio clips. • For example, the following array could be the colors the first player selected: 2 3 2 1 0 3 2 1 This array would mean that Player One clicked on the following colors: Green (2) Yellow (3) Green (2) Blue (1) Red (0) Yellow (3) Green (2) Blue (1) When the REMEMBER GAME button is selected • Normally, Player Two would click buttons to repeat the sequence of Player One. However, to make this simpler (since we are just learning JavaFX GUIs), simply display the colors names in a label in the pane: • For the example above, you would display: Green --Yellow --Green --Blue --Red --Yellow --Green --Blue When the END GAME button is selected • Close the application. Disabling Buttons • It is a fairly common practice to disable buttons when it is best for the user not to use the given button for a period of time. The following would disable a button named redButton: redButton.setDisable(true); The following would enable a button named redButton: redButton.setDisable(false); • When the application starts, the color controls and REMEMBER GAME button should be disabled. • When the START GAME button is selected, the color controls should be enabled and the REMEMBER GAME button should be disabled. • After a game begins and 8 colors have been selected, the REMEMBER GAME button should become enabled and the color buttons should be disabled. Special Notes • Player One should be told how many colors he/she has selected each time they click a color. When the colors reach 8, they should be told they have selected 8 and they should not be allowed to select more. • Watch for out-of-bound errors on the arrays. • Make sure the users always know what is going on with the application. NEW CONCEPTS ASSESSED AND ILLUSTRATED (IN ADDITION TO ANY PREVIOUSLY LEARNED) • JavaFX components and audio clips. • Review of single-dimension arrays. • Using sound clips in a Java application SOFTWARE REQUIREMENTS Standard Requirements  Include a comment block at the top of your program to clearly identify (1) your name (2) the current date (3) your instructor (4) your class and (5) the purpose of this program (Java class). Significant penalty for missing this requirement and for poor documentation.  Use the Programming Standards document introduced in Module 1 to apply documentation standards correctly, consistently, and thoroughly in all Java classes submitted for grading. If a Java class was provided by your instructor (some weeks), you must update the documentation for the given class. Significant penalty for missing this requirement and for poor documentation.  Properly zipped submissions for grading. No missing files. ZIP file extension. No credit for incorrectly zipped files or for uncompressed files.  All code is free of compile-time errors. No credit is given for assignments with compile errors.  Incorporating what you have previously learned to date as appropriate for this assignment. Requirements Specific to this Assignment  Select appropriate JavaFX components for the application.  Use exactly two classes for this solution. Your solution should mirror how the textbook illustrates using one class to create a pane and one class to create a driver which instantiate an object from your pane class. This file contains the main() method.  Games works are described in the guideline.  Audio clips work as outlined.  GUI has an attractive layout and is easy for the user. No unexpected results or errors occur.  Arrays are used properly. No out-of-bound errors. New games refresh the array correctly.  Zip together your two source code files (.java file extensions) and sound clips. If other resources are used (images, etc.) they are to be included. Submit only 1 ZIP file that contains all files needed to compile and run the application. SECURITY CONSIDERATIONS Incorporate the security tips you learned from Towson in all applications you create

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

* Program Name: Simon
* Author:
* Instructor:
* Date Written:
* Course:
* Description: This is the Simon Class. This class is used for Java Fx form and
* buttons with the methods relating to a simon game with a few changes. First,
* the form is loaded. Second, the player is to click new game. Third, the
* player clicks on the colored buttons only going to 8 selected colors. Fourth,
* the other player in this case will see the pattern previously entered.
package simon;
// Imported needed classes
import javafx.application.Application;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.stage.Stage;
import javafx.geometry.Insets;
import javafx.scene.control.Label;
import javafx.scene.layout.GridPane;

// Beginning of the Simon Class
public class Simon extends Application
    // Declare Java FX controls
    private Button redButton;
    private Button blueButton;
    private Button greenButton;
    private Button yellowButton;
    private Button newGameButton;
    private Button rememberGameButton;
    private Button endGameButton;
    private Label simonInstructionsLabel;
    private Label simonInstructionsNameLabel;
    // Declare and setting array to store to index and counter of colors
    private int playerSimonIndex=0;
    private int playerColorSelCntr=0;
    // Declare an array to store the colors by number in Array
    private int[] player1SimonAry = new int[8];
    // Beginning of the Start Method
    public void start(Stage primaryStage)
       // Declare and set Audio Clips with the WAV files
       AudioClip redAudioClip = new AudioClip(Simon.class.getResource("Red.wav").toString());
       AudioClip greenAudioClip = new AudioClip(Simon.class.getResource("Green.wav").toString());
       AudioClip blueAudioClip = new AudioClip(Simon.class.getResource("Blue.wav").toString());
       AudioClip yellowAudioClip = new AudioClip(Simon.class.getResource("Yellow.wav").toString());
       // Declare and set an array of audio clips
       AudioClip [] simonColorAryAudioClips = {redAudioClip,blueAudioClip,greenAudioClip,yellowAudioClip};
       // Declare and set the values for the scene and grid of the window pane
       Scene simonScene=null;
       GridPane simonGridPane=null;
       simonGridPane=new GridPane();
       simonScene=new Scene(simonGridPane);
       simonGridPane.setPadding(new Insets(12,12,12,12));
       // Declare and set the Java FX Buttons for the game
       redButton = new Button("Red \nControl 1   ");
       redButton.setStyle("-fx-background-color: #CC0000");      
       greenButton = new Button("Green \nControl 2   ");
       greenButton.setStyle("-fx-background-color: #00CC00");
       yellowButton = new Button("Yellow \nControl 3   ");
       yellowButton.setStyle("-fx-background-color: #CCCC00");
       blueButton = new Button("Blue \nControl 4   ");
       blueButton.setStyle("-fx-background-color: #0000CC");
       newGameButton=new Button("New\nGame   ");
       rememberGameButton=new Button("Remember\n Game");
       endGameButton=new Button("End\nGame");
       simonInstructionsNameLabel= new Label("Instructions:");
       simonInstructionsLabel = new Label("Click on Start Game \nor Exit Button");

       // Place the Java FX Buttons on the Grid Window Pane
       // Sets the title of the game
       primaryStage.setTitle("Simon Game");
       // Sets the scene on the stage
       // Shows the stage of items;...

By purchasing this solution you'll be able to access the following files:

for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats