CIS 542 - Spring 2012

Lab Assignment #6

March 22, 2012

Due: March 29, 4:30pm

Due: Apr 5, 4:30pm

In this assignment, you will build upon the typing game from lab assignment #5 and add additional features. In particular, the application will have multiple screens on which a user can login, see a list of top scores, and play the typing game.

Since this assignment builds upon the first one, clearly you must have the basic typing game functionality in place already. If you did not complete the last assignment, please contact the instructor.

Step 1. Support for multiple sentences
First, modify your program so that it stores 5-10 short (no more than 100 characters or so), meaningful English sentences. Each time the user asks for a new sentence, you can either choose a random one, or go in sequence; that is up to you.

Also modify your program so that the "Try again?" dialog asks the user whether they want to try the same sentence or a different one.

Last, make sure your program tracks the best time for each separate sentence, not just the best time overall. This should be stored to persistent storage: you can decide which mechanism is best.

Also, make sure you track the login name (see below) of the user who achieved that top score.

Step 2. Login screen
Now create a screen (Activity) in which the user enters his name, as shown in the screen shot below. You do not have to use any sort of password or anything like that. The user can also choose to quit the application here, too.

Step 3. Main menu screen
After the user logs in, he is shown a "main menu" in which he can either play the typing game, see the top scores for each sentence (as described in Step 5), or log out (as described in Step 6). You can implement the menu any way you like; here's an example using buttons:

Step 4. Modify gameplay
If the user chooses to play the typing game, the functionality here is exactly the same as in lab #5, except that, when the top score (lowest time to type the sentence correctly) is displayed, the name of the user who achieved that top score is also shown, like this:

Note that because we haven't looked at persistent storage yet, the top scores for each sentence may be lost across multiple executions of the program. That is, if you exit the application and restart it, the top scores might disappear. That's okay for now, though.

Be sure that you store the top score for each sentence in persistent storage: you can use key/value pairs (properties), a flat file, or SQL. The top score should not be lost across executions of the app.

If the user hits the "Quit" button while playing the typing game, you should go back to the main menu, instead of quitting the application. You do not need to show a dialog in this case (but it's okay if you do).

Step 5. Top scores
If, from the main menu, the user chooses to see the list of top scores, you should show the sentence, the user with the top score, and the amount of time for each of the sentences stored in your application. You can use whatever Layouts or Views you like to display this information. Here's a fairly lame way of displaying it, just using TextViews:

Step 6. Logging out
If, from the main menu, the user chooses the "Quit" button, he should then go back to the "log in" screen, so that a different user can log in and play (that is, you do not exit the application from the main menu, only from the login screen). Be sure to display an "Are you sure?" dialog before logging out.

Something to think about...
One of the challenges in programming apps for mobile devices is that you can never really be sure what the user is going to do (this is also a challenge for web programming). In the middle of using your application, the user may do something unexpected like hit the "home" or "back" button, make or receive a phone call, or get a warning from the device that the battery is low. That is, you cannot ever guarantee that the user will follow the sequence of program usage that you may envision when designing your application.

As you're testing your application, play around with things like hitting the "home" or "back" button at random points of your program, and see if your application behaves as you might expect it to. Does data get lost? Does the program crash? If the user leaves the application and comes back, does he go to the screen where you think he should be?

If the program does not work as you'd like it to, revisit the lecture on the Activity lifecycle and read the online documentation to figure out which methods you should be implementing/overriding, and try to make your application more robust (i.e., more resistant to breaking during unexpected circumstances). The TAs will try to break your application as part of the grading process, so make sure it is robust!

Academic Honesty
As in the previous lab assignments, you may work with one other student on this assignment (even when you are outside the lab). However, you may not discuss or share solutions with any other students, nor should you be receiving any help from outside sources, including students not taking this course or online resources. If you run into problems, please ask a member of the teaching staff for help. Failure to abide by the academic honesty guidelines will result in a grade of 0 for this assignment.

This assignment is due at 4:30pm on Thursday, March 29 April 5. After that, late submissions will be subject to a 10% per day deduction.

If you are working with another student, only one of you needs to submit this assignment.

For this particular assignment, please follow these specific instructions:

Please be sure that you are only submitting one zip or tar file that includes your Eclipse project and your README file.

Failure to properly follow the submission instructions could result in a delay of grading your assignment and/or a lateness penalty, so please be sure to do it correctly!

Updated: Thu Mar 29, 10:58am