Mobile Application Development

Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

PL/EX/02 REV:00/00.00.

0000

SRI LANKA TECHNOLOGICAL CAMPUS


BACHELOR OF SCIENCE HONOURS IN SOFTWARE ENGINEERING
BACHELOR OF SCIENCE HONOURS IN DATA SCIENCE
BACHELOR OF SCIENCE HONOURS IN CYBERSECURITY

YEAR 3 – SEMESTER 1 – July 2022

End Semester Examination

CCS531 Mobile Application Development

Three Hours

No. of Questions: 01

Important Instructions to the candidates

● The mode of the exam will be in the form of an online, open book examination
● If a page or a part of this question paper is not printed, please inform the supervisor ,
invigilator or the examination unit via the hotlines provided
● Candidate's registration number, Module code and Module Name should be written clearly
and legibly on all answer sheets
● Candidates must not seek, give or receive assistance of any kind during the exam. Any
cheating, any attempt to cheat, assisting others to cheat, or participating therein, or engaging
in such improper conduct is a serious violation and will generally result in disqualification of
the candidate’s paper, and any other disciplinary action as may be deemed appropriate.
● Candidates are requested to adhere to the examination guidelines circulated
PL/EX/02 REV:00/00.00.0000

Special Instructions for Students:


 Pre-requisites folder contains two files.
I. Preferences.java file should be added to your package while building the app. It’s
mentioned as a step in the paper, make sure you add it to that step.
II. Demo.mp4 is for your reference, to check what the end product/app should be like
after it’s completed.
 After completing the app, please make sure you create a folder with your reg number, copy
the app folder into that folder and compress as a zip file and submit it.
 It is an open book exam, but you are not allowed to use the internet.

Q1. This question has nine steps, follow all the steps.

1. Load android studio and create a new Android application with the following.
Application Name: HealthApp
Package Name: lk.sltc.healthapp
Project Location: Desktop/{YourRegNumber}/
Phone and Tablet - min SDK – API 30

Create Empty Activity with the following.

Activity Name: MainActivity


Layout Name: activity_main

2. Open build.gradle(Module: HealthApp.app) file (ref: figure 1) and add the following line to
the dependencies block (ref: figure 2), and then click on “sync now” and wait till it
completes.
implementation 'com.google.code.gson:gson:2.9.0'

Figure 1: build.gradle(Module: HealthApp.app)


PL/EX/02 REV:00/00.00.0000

Figure 2: gson dependency addition

3. Create a model class for Goal and create the constructor and getters for all attributes
mentioned below. (Total: 20 marks)
code - string variable
name - string variable
description - string variable

Create a model class for Person and create the constructor for firstName, lastName and
email, and create getters and setters for all the attributes mentioned below.

firstName, lastName, email - string variables


goal - use Goal data type
height, weight - double variables
age - int variable
gender - string variable

Drag and drop the Preferences.java file (which is given to you as prerequisites) to your main
package. Open up the Preferences.java file and go through each and every method and
study what each method does.

4. In activity_main.xml do the following. (Total: 20 marks)


a. Design the layout according to the screenshot below. Please give appropriate ids
and constraints to each and every component.
b. Define hints for the text fields as per the screenshot below.
PL/EX/02 REV:00/00.00.0000

Figure 3: activity_main.xml

In MainActivity class do the following.


c. Define EditText and Button attributes for each and every component in the layout.
d. Initialize the attributes by calling findViewById method in the onCreate method.
e. Define a SharedPreferences variable and initialize it by calling the
getSharedPreferences method. ( give it a file name and use the mode private)
f. Define an onClickListener to the next button and inside the onClick method do the
following
i. Create a person object by using the values of the edit texts.
ii. Save as current person by calling the saveAsCurrentPerson method.
iii. Create another empty activity and give it the name “GoalsActivity” and
navigate to that activity by calling startActivity method.

5. In activity_goals.xml do the following. (Total: 20 marks)

a. Add a new layout file and name it list_goal_item.xml and design the xml so that it
can hold on to one of the items in the list given below. Use two TextViews.
PL/EX/02 REV:00/00.00.0000

b. Add a RecyclerView to activity_goals.xml and give it the id rv_goals and add


constraints appropriately. Set the layout manager to a linear layout manager and set the
listitem attribute to the item layout you created.
c. Add a back button and give it an appropriate id and define and initialize an attribute
in the GoalsActivity.

Figure 4: activity_goals.xml

In GoalsActivity.java do the following,


d. Create a SharedPreferences variable and initialize it with the same file given in
MainAcitivity.
e. Create a global List of generic type goals (List< Goal>)
f. Create a method called populateGoals and create goal objects (Fat loss, Build
muscle, Lean gains and General Health) and add them to the list.
g. Call the populateGoals method in the onCreate method of the activity.

6. Right click on your package and create a new Java class and name it GoalListViewHolder (The
super class should be RecyclerView.ViewHolder) . (Total: 5 marks)
a. Define attributes to hold each of the views in list_goal_item.xml.
b. Create the constructor, and initialize each of the attributes using findViewById.
PL/EX/02 REV:00/00.00.0000

7. Right click on your package and create a new Java class and name it GoalListViewAdapter
(The super class should be RecyclerView.Adapter). Please do the following. - (Total: 10
marks)
a. Define attributes of type List<Goal>, Activity object and SharedPreferences, and
create a constructor to pass values for these three attributes.
b. Implement getItemCount method and return the size of the gosl list.
c. Implement onCreateViewHolder method and use the Layout Inflater to inflate the
item view and create a ShoppingListItemViewHolder object and return it.

d. Implement the onBindViewHolder method and do the following.

i. Set the name text and description text of the view holder by using the
appropriate goal object (use the position passed to the onBindViewHolder method to get
the goal object)

ii. Define an onClickListener to the itemView and inside the onClick method
update the goal of the current person by calling the appropriate methods in the Preferences
class.

iii. Create another empty activity and give it the name “PersonalInfoActivity”
and navigate to that activity by calling startActivity method.

e. In GoalsActivity create a new GoalListViewAdapter object and set it to the recycler


view.
PL/EX/02 REV:00/00.00.0000

8. In activity_personal_info.xml do the following. (Total: 20 marks)


a. Design the layout according to the screenshot below. Please give appropriate ids
and constraints to each and every component.
b. Define hints for the text fields as per the screenshot below.

Figure 5: activity_personal_info.xml

In PersonalInfoActivity do the following,


c. Define EditText and Button attributes for each and every component in the layout.
d. Initialize the attributes by calling findViewById method in the onCreate method.
e. Define a shared preferences variable and initialize it by calling the
getSharedPreferences method. ( give it a file name and use the mode private)
f. Define a onClickListener to the next button and inside the onClick method do the
following
i. Update the current person by calling the appropriate methods in the
Preferences class.

ii. Create another empty activity and give it the name “SummaryActivity”
and navigate to that activity by calling startActivity method.
PL/EX/02 REV:00/00.00.0000

9. Show a summary like below using the calculateCalorieRequirement method in the


Preferences class. (Total: 5 marks)

Figure 6: activity_summary.xml

End of Question Paper

You might also like