Lab 2 - Ping-Pong
This lab is not for marks. However, you are strongly encouraged to complete this lab as it provides you with an opportunity to develop your skills. You do not submit your solution, but teaching assistants can provide feedback during the lab.
Build a mobile app that meets the following:
- The app must be Andoid-native; must target IceCream as minimum API level; and must adhere to the MVC architectural design principle.
- The UI must consist of an appropriately-captioned button. When the button is clicked, Ping must appear under it. When the button is clicked again, Ping is replaced with Pong. When the button is clicked again, Pong is replaced with Ping. Etcetera.
The app must have three components: A model named
PPModel, a view encoded as an XML file, and an activity named
- Create a class named
- Add a private attribute of type boolean.
- Add a public constructor that initializes the attribute to true.
- Add a public method that returns either Ping or Pong. The first time you invoke the method it returns Ping. The second time Pong. The third time Ping. Etcetera.
Add to the class
PPActivity a method that sets the text of the view to either Ping or Pong.
Develop a view with a single button and a text area below it.
This is your second task.
This is your third task.
Change the colour of the text from red to blue to red to blue, etcetera.