Lesson 4: User input
Year 8 – Programming – Mobile app development
Lesson 4: User input
Objectives
In this lesson, you will
2
User input
Starter activity
It is common for software applications to obtain data from the user.
Questions
Think/pair/share.
3
User input
Starter activity
Text boxes (allowing for the user to input a text string)
Checkboxes (allowing for the user to indicate a yes or no response)
Button (linked to an event that will capture and process the data when it is clicked)
4
getText()
Activity 1
getText ("id") is a built-in subroutine that collects the text entered into a textbox; “id” is to be replaced with the name given to the text box.
5
You can use an event handler to determine when to collect the data and what to do with it once it has been collected and linked with a variable.
Theme park tickets app
Activity 1
The purpose of this app is to allow the user to enter in the number of adult and child tickets required.
Once the user selects the submit_button, the data will be captured and processed and total will be displayed in the result_label.
6
Theme park tickets app
Activity 1
7
Place the blocks in the correct order to form a working segment of code.
Solution
Activity 1
8
Decompose the problem
Activity 2
Decomposition is breaking a problem down into more manageable chunks.
Programming an app for a mobile device is a daunting task to undertake.
Decomposing the problem helps us make the task less daunting and more achievable.
9
Decomposition example (Tappy Tap App)
Activity 2
10
Step | Further decomposition |
Screens |
|
Welcome screen |
|
Game play | |
Results screen | |
Open your project diary and spend ten minutes decomposing your app project with your partner.
Decomposition example (Tappy Tap App)
Activity 2
11
Step | Further decomposition |
Screens |
|
Welcome screen |
|
Game play |
|
Results screen |
|
Open your project diary and spend ten minutes decomposing your app project with your partner.
Develop your app
Activity 2
Now that you have decomposed the problem and have designs for the screens, you are ready to start developing your app.
12
Pair programming reminder
Activity 3
While you are developing your project, you and your partner will take turns to be the driver and the navigator. You will swap roles regularly as directed by your teacher.
13
The driver: Your role is to control the keyboard and mouse and place the code block in the correct places.
The navigator: Your role is to help support the driver by watching for any mistakes, reading the instructions to the driver, or seeking support if needed.
App development
Activity 3
How to be successful with pair programming:
Both partners must be contributing equally.
14
Your project diary: Milestone 1
Activity 4
In your pairs, you now need to reflect on what you have achieved this lesson.
15
Next lesson
Summary
In this lesson, you…
Looked at how to handle user input from a text box
Decomposed your project
Make a start developing your project
Next lesson, you will…
Develop your app further
16