Android programming: Activities and Intents
Recall the rules for flipped classrooms: do the work alone or with a partner that is unique for the semester. You can find the github link on canvas, ed discussion and via github classroom. https://classroom.github.com/classrooms
Only one student needs to submit this code, but both students may do so if they wish. This assignment should be submitted through github (sorry, partners can¡¯t share the repos- itory). Include a README at the top directory level with all the course README infor- mation including both student¡¯s EIDs.
For this assignment, you have been given part of a game. The game is functional, with the exception of everything having to do with intents and switching between activities. You are only given the code and XML layout files.
The game consists of two screens, or Activities. On the first screen is a high score list. A user must put in their name before starting a new game. You should check to see what the user has put in a name, and if the name is empty you should refuse to start the game and provide a Snackbar message explaining why the game won¡¯t start.
After pressing start, the app should transition to the second screen. It should pass the player¡¯s name to this screen. The second screen is a guessing game. The user guesses a number and is told if it is ¡°too high¡± or ¡°too low¡±. When the user gets the number correct the app transitions back to the first screen. A Snackbar message is shown to the user with the contents, ¡°Correct¡±. The GuessingGame class passes back the user name and the score, which the MainActivity uses to create a Score object and add it to the high scores list. The more guesses, the lower the score.
If user ¡°Hintme¡± plays twice and earns scores 970 and 997, then that name should appear twice in the high score list.
1. Files of interest
(a) AndroidManifest.xml You will need to add something here and you will need to figure out where to add it. There is a note here about a property which should make sense once you figure out what you are adding.
(b) MainActivity.kt This is the main activity and it implements the high score list. It needs to pass information to GuessingGame. Everything that you need to do is marked in the code this way:
// XXX Write me (possible description of what needs to be written)
(c) GuessingGame.kt This class runs the game. It passes information back to MainActivity. You will need to add some things in here, which are also marked with XXX in a comment.
(d) activity main.xml and content main.xml The layout for MainActivity. No modifications needed.
(e) game.xml The layout for GuessingGame. No modifications needed.
Code Help
(a) Call the function computeScore() in GuessingGame to get the score. No argu- ments are necessary, it is already tracking the needed information in class vari- ables.
(b) All locations where you must insert code have been clearly marked.
(c) To get the answer to the guessing game displayed in a Snackbar, use a name that starts with ¡°hint¡±.
(d) Videos 5 and 6 from Derek Banas¡¯ How to Make Android Apps video series on youtube is quite relevant. See the page describing the code and video here.
浙大学霸代写 加微信 cstutorcs