In this test, you have to develop a mobile app. You are already given the
view (activity_main.xml
file). You have to implement the model and the
controller. More details are provided below.
The given view looks as follows.
Note that in the above image at the top it says MidtermC whereas it says MidtermB in Android Studio. You do not have to change this.
The view contains a single button labelled Press me. Whenever the button is
pressed, the pressed
method of the controller is invoked.
Implement the Toggle
class. Its API can be found
here.
Do not change the name of the class. Also, do not change the signatures
(name and parameters) of any of its methods.
Implement the MainActivity
class. Its API can be found
here.
You may want to add an attribe to the class and initialize the attribute in the onCreate
method. Furthermore, you may want to add code to the pressed
method. In this method,
toggle it, set the text of the button (it should alternate between "Press me" and "Again") and set the
colour of the button (it should alternate between green and red).
Before 19:45, submit your code as follows.
You can repeat the above steps as many times as you like throughout the test; every submission overwrites the previous one. Submission of a file does not imply that you can't continue to work on the file and resubmit it.
If you submit after 19:45 but before 19:50, you will get a penalty of 1 point per minute (the test is worth 15 points).