Lab 5 - Tip Calculator
Before you Start
- If needed, review these videos.
- Check if your mark for Lab 3 has been recorded here (log in with your Passport York credentials). You should see something like the following screenshot. If you cannot find your mark, please show Lab 3 to the teaching assistant again.
ePortfolio Entries
Each entry consists of a web page and a zip file.
- Click on the assignment at the course website in Moodle. Submission is only open during the week of the lab and the week that follows.
- Zip the
src
folder of your Android project and store the zip file on the desktop (the video entitled AndProject shows you how). Name the file Xsrc.zip
(where X
is the name of the lab) and drag it to the lab submission site.
- Create your web page (inside Moodle) so it includes the following sections:
- Title and Authors:
This is a two-line header, the first identifies the lab (lab number and name) and the second identifies the team members. For each member, write the Passport York username and the full name.
- Introduction: This is a paragraph in which you describe what you did in this lab. The paragraph is limitted to at most three sentences so you need to abstract the essence of what you did rather than the detailed steps taken.
- Results: This starts with a paragraph that describes your findings: did your work achieve what was required, where there any unexpected results, did certain things not work, etc. This paragraph must be followed by screenshots and/or links to YouTube videos that showcase your findings in action.
- Discussion: In this section you should answer any question asked in the lab document. You can also add here any comment you may have (e.g. what you learned from the lab, what was particularly challenging, etc.).
- Your entry is saved as "draft" and remains as such (so you can optionally edit it) until you submit. Once you are happy with your draft, please ask the teaching assistant to mark your work. If the teaching assistant is happy with your code and web page, click the submit button. Also provide the Passport York username of both members of the group to the teaching assistant.
Programming Environment
- You will need a laptop with the EECS VBox (build-2016) installed
(additional information can be found here). This is the same as the one used in EECS 1012. You can use your own laptop or borrow a Departmental one.
- You will also need an Android tablet to deploy your app. A tablet will be given to each pair of students at the beginning of the lab session. You can also deploy your app on your own Android device but the teaching assistant will only mark it on the Departmental tablets.
- Make sure you are familiar with the VBox environment. In particular, you should be able to transfer files from it to the outside; i.e. to the host through a shared folder; to a cloud service (such as Google Drive or DropBox) through a browser; and to a USB drive.
- Make sure you are familiar with capturing screenshots and videos so you can embed them in your ePortfolio entry.
- If you are not 100% comfortable with any of the above then review the Lab Tools document of EECS1012.
The Lab
View
Implement a view that has
- a TextView labelled "Enter Check Amount",
- an EditText which is initially empty for the entry of a decimal number,
- a TextView labelled "Select Tip",
- three RadioButtons labelled "10%", "15%" and "20%". Place those three into a RadioGroup. Initially, the button labelled "15%" should be selected.
- a TextView labelled "Enter Number of People" for the entry of a number,
- an EditText for the entry of a number, intially containing 1,
- a TextView, which is initially not labelled, but will be set to "Total = " followed by the sum of the check amount and the tip rounded to two digits (for details, see below), after the button has been clicked,
- a TextView, which is initially not labelled, but will be set to "Per Person = " followed by the amount per person rounded to two digits (for details, see below), after the button has been clicked, and
- a Button labelled with "Calculate Tip".
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.