This assignment again uses the ideas presented in Chapter 5 of the text to create the beginnings of another learning game for children just learning about the alphabet. In this game, the user needs to push all the letters of the alphabet to "win". If the user has not pushed all the letters, a message on the bottom of the screen indicates there are more letters to type. If the user has pushed all the letters, then a "win" message appears.
If you don't remember how to do any of the steps (like, copying, zipping, etc), please refer back to Lab 1.
First, you will need to copy over the scenario for this assignment. If you are working from home, you can download the scenario here. If you are in lab, the scenario is located in /eng/class/notes/cse113/scenarios/PracticeAssignment6.
Take note of the following classes in the scenario:
Below is a description of the tasks you need to complete for this scenario.
Letters should react when the user clicks on the proper key on the keyboard by changing their image to the proper "Pressed" image. You should not create multiple letter classes, but rather make the letter class' constructor accept a String that represents the letter from the keyboard so that the letter knows which letter it is supposed to react to. You can use that information (the string containing the letter) to construct the names of the image files you will need to display.
In order to test out your letter buttons, it will probably be easiest to put the code right in the LearningGame constructor. Try out a few different letters and place them anywhere on the screen. Make sure their images change when you click on them. We will work on positioning all the letters in a moment.
Each letter image is 77x77. Given the size of the world, you will only be able to put at most 7 letters across the screen before running out of room. Therefore, we will need 4 rows to place the letters into the world.
Since we will have four rows of letters, we will need four loops. Begin setting up the loops so that each one executes 7 times (except for the last one which will only execute 5 times). Inside the body of the loop, add a letter to the world. Have them all react to the same key on the keyboard for now (or a different key for each row if you'd like), but set up the placement of the letters so that they appear in rows and are not placed on top of each other. Run the program frequently during this stage to ensure that the world looks like you want it to.
Create four arrays to hold the letters from each of the visual rows on the screen. Use the information from the array inside the loop body so that all the letters of the alphabet are placed on the screen. Run the program to be sure it is working.
If you play the "game" at this point, you will notice that even if you type all the letters of the alphabet, the message never changes. This is because when the key is pressed, we never tell the recorder about it. Insert the code inside the act() method of key to tell the recorder that the letter was pressed. You will be calling the keyPressed(String key) method and passing in the appropriate information to the recorder.
Now when you run and press all the keys of the alphabet, you should get the congratulatory message.
Once you have completed your work, you will submit the zipped up version of the Practice Assignment 6 scenario.
For directions on submitting, please see here.
This practice assignment is due on Monday, May 2nd at 11:59:59pm.
Please make sure to look at your grading information on Web-CAT. See the grading information page for more details about how to interpret Web-CAT grade reports.
The following tests were run on your assignment submission.
Lab authored by Adrienne Decker