Lab 5 - Tip Calculator

Before you Start

ePortfolio Entries

Each entry consists of a web page and a zip file.

Programming Environment

The Lab

View

Implement a view that has

Initially, the view should look like the following.

Model

Implement a model with this API. Recall that private attributes do not show up in the API. Hence, you have to determine which attributes are needed. Hint: have a look at the constructor in the API.

Controller

Implement a controller with this API. Recall that a controller is called an activity in the Android world. A default implementation of such a class is produced when an Android project is created.

onCreate method

When the Android project is created, an activity class with the following onCreate method is generated.

protected void onCreate(Bundle savedInstanceState) 
{
  super.onCreate(savedInstanceState);
  this.setContentView(R.layout.activity_tip_calculator);
}

Note that this. is missing in the last line of generated code, but can be added without changing the behaviour of the code. Also note that activity_tip_calculator is derived from the name of the Android project (in this case TipCalculator) and, hence, might be different.

No changes need to made to this method.

buttonClicked method

First, design an algorithm. It should consist of roughly eight steps. These steps can be added as comments to the method body. Secondly, implement the algorithm.

If the check amount is 50.00, the tip is 10% and the number of people is 5, then

Total = 55.00
Per Person = 11.00
should appear between the EditText to enter the number of people and the button.

Test

Deploy your app on a tablet and test it.

Credits

This lab is based on an assignment designed by Bjoern Hartmann which can be found here.