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.
Requirement
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.
Design
The app must have three components: A model named PPModel
, a view encoded as an XML file, and an activity named PPActivity
.
Implementation
PPModel
- Create a class named
PPModel
.
- 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.
PPActivity
Add to the class PPActivity
a method that sets the text of the view to either Ping or Pong.
XML file
Develop a view with a single button and a text area below it.
Testing
This is your second task.
Deployment
This is your third task.
Extras
Change the colour of the text from red to blue to red to blue, etcetera.