Starting from:
$30

$24

Lab 3 Pig Game with a Menu and State Persistence Solution

Purpose: This lab is designed to give you practice:




Creating a menu to allow users to customize your app’s settings.
Using an intent to launch a new Activity.



Persisting the state of your app so that it is restored after device rotation or resuming the activity.



Part 1: Textbook Exercises




Do the exercises shown below:




5-1, Modify Tip Calculator layout



6-2, Improve the listener for the Key events



8-1, Experiment with menus and settings on the Tip Calculator



8-2, Work with menus on the Tip Calculator



8-3, Work with preferences on the Tip Calculator






Optional, do these if you have extra time:




5-2, Add radio buttons and a spinner



6-1, Use anonymous classes for event listeners



7-1, Use built-in themes with the Tip Calculator



7-2, Use styles on the Tip Calculator



7-3, Modify a theme used by the Tip Calculator



Upload a text file to Canvas in which you will report, for each exercise above, whether you:




Followed all the steps shown in the book and successfully compiled and ran the program (where applicable).
Loaded the completed solution, experimented with the code, and ran the program (where applicable).
Read through the steps and inspected the relevant code listings without writing or running a program.
Didn’t do any of the above.









Part 2: Pig Game v2.




Modify the Pig Game from the previous lab by adding the following features:




State persistence



Use a SharedPreferences object to save the state of your app when the device is rotated, or when the app has been stopped and then resumed (you can test this by using clicking on the Force Quit button in Settings, App, your app).




Menu
Add a menu to the Pig game. The menu should have at least two items: o About

For now, you can just pop up a toast when the user selects “About”. (In a future lab, you will add code to display information about the app.)




o Settings

Selecting the “Settings” item should launch a new PreferenceActivity.




Settings
For the settings activity, you can choose which preferences you will allow the user to set. Some possibilities are to allow users to select things like: Number of die, sides on a die, score to play to (other than 100), an AI mode (the user can play against the app), AI settings (max rolls, max score), etc. The only requirement is that you add at least 4 settings.





More products