HCI Lab: Assignment 1
A Hello to Android
Due Date: April 8, 2019 @ 21:00pm (Tuesday Class) April 10, 2019 @ 21:00pm (Thursday Class)
Goal
The goal of this assignment is to gain some practical experience programming on Android.
Overview
For this assignment, you will set up your first android project. You will then modify the MainActivity to display some text. You will then write some code to perform a simple programming task that updates text displayed in your activity.
You will submit your Android Studio Project files, including your MainActivity.java file along with screenshots of your output when running your application on the Android emulator.
Tasks
1. Create a new Android Application Project in Android Studio
2. Load the application onto your Android Emulator and take a screenshot showing your Application¡¯s Name being displayed (0.5 pts)
3. In your MainActivity.java, write a function called calculateFibonacciNumber using the javadoc comment below. Be sure to use appropriate modifiers (visibility, memory management, etc) for the method declaration. (3 pts)
/* Takes an integer i and calculates the i-th fibonacci number and * returns this number
* @param i – the i-th fib number to calculate
* @return fibNumber – the calculated fib number
*/
// TODO: fill in method
HCI Lab 2019 Spring Assignment1
1/2
4. Modify your strings.xml file to include a string will contain two number arguments related to calculating a fibonacci number. (0.5 pts)1
a. For example, when provided with the i-th number ¡°7¡± and it¡¯s fibonacci number ¡°13¡±, your string should display the following:
¡°The Fibonacci number for the number at index 7 is 13.¡±
b. You should not be hardcoding the numeric values– the string should be
parameterized.
5. Now modify layout_main.xml so that your app contains two TextViews. One with the id:
¡°text_main¡± and another with ¡°text_fib_number¡±. (1 pts)
6. Now using using your calculateFibonacciNumber method, and references to the
TextViews you created in your layout file, modify your MainActivity.java, so that your display the index 20 and its calculated fibonacci number in your ¡°text_fib_number¡± using your fibonacci number string. (4 pts).
7. Ensure your code is well-written, legible, and clean. Style points are worth (1 pts)
Grading
¡ñ Displaying your app name (0.5 pts)
¡ñ Correct Fibonacci Implementation, error handling (3 pts)
¡ñ Correct Number String Parametrization (0.5 pts)
¡ñ Displaying two TextViews with proper ids (1 pts)
¡ñ Displaying 20th index and its fibonacci number using your functions and the
parameterized string (4 pts).
¡ñ Code Cleanliness/Style points (1 pts) – Follow Guidelines here:
https://github.com/ribot/android- guidelines/blob/master/project_and_code_guidelines.md#22-java-style-rules
Total for A1: 10 pts
Submission
You should submit the android project files for the application and also include screenshots of you app displaying your final output.
Compress any images and your code in a zip file named using the format STUDENTNO_STUDENTNAME_A1.zip. Submit it to your commissary in charge of studies.
1 Useful resources: https://developer.android.google.cn/guide/topics/resources/string-resource.html#ÉèÖÃ×Ö·û´®¸ñʽ
HCI Lab 2019 Spring Assignment1
2/2