ITECH2000-week1-12 Question PDF

Title ITECH2000-week1-12 Question
Author Sudhir Kumar
Course Mobile Development Fundamentals
Institution Federation University Australia
Pages 51
File Size 3 MB
File Type PDF
Total Downloads 51
Total Views 144

Summary

week 1 - 12 important questions...


Description

ITECH2000 Mobile Development Fundamentals Module 1 Lab/Tute Exercises Part 1 – Review Questions Q1. What are the two main types of mobile computing devices? Mobile Phones and Tablets Q2. What is the name of the mobile operating system developed by Apple? ios Q3. What is the name of the mobile operating system developed by Google? android Q4. Briefly describe the evolution of the generations of mobile network technology. Q5. What are three disadvantages that smartphones have over desktop devices? Week: 1 slide: 27 Q6. What are three disadvantages that smartphones have over desktop devices? Q7. What are the four important questions that you must ask before developing an app?

Slide 29

Part 2 – Pseudocode and Introduction to AppInventor Task 1 – Pseudocode Refresher In previous courses (such as ITECH1101 IT Problem Solving) you will have been exposed to the concept of pseudocode as a high-level way to convert a problem definition into a solution. In ITECH2000, you should continue to use pseudocode as a way to plan your program before you start building it in MIT AppInventor. a. Watch the following video on pseudocode:  https://www.youtube.com/watch?v=PwGA4Lm8zuE b. Download the “SimpleAddition.zip” file from Moodle, unzip it, and then follow these instructions: • In the PDF file, take a look at the problem statement, the pseudocode and program representations. Note down any similarities and differences you identify. • Most of the apps we create in ITECH2000 will involve three types of behaviour: INPUT, PROCESSING, and OUTPUT. Try to identify these three behaviours in the pseudocode and program.

Now it’s your turn to write some pseudocode. Consider the following two scenarios and write out the main algorithm using pseudocode. Don’t worry too much about syntax, just try to get the main steps down onto paper. Follow the process as suggested in this week’s lecture, and focus on any input, processing, and output behaviours. Ask your tutor for feedback when you have finished. Scenario #1 Federation University has asked you to create an app that will be used by student mentors to record the details of students who attend events during orientation week. The app should record the name, student ID number, and main FedUni campus that the student attends. Once the details have been entered, the student taps a button and the details are saved to variables. The screen then displays a welcome message for 5 seconds that includes the student’s name, and the input fields are cleared for the next student. Scenario #2 A local event planner wants you to create an app that determines seating arrangements at events. The app will take in the total amount of tables available at the venue, and the total number of people who will be attending the event. When a calculate button is pressed, the app should divide the number of people by the number of tables, and store the result in a variable named seatsPerTable. A message should be displayed on the app to inform the user of the number of seats required per table. Scenario #3 You have been asked to create an app that checks whether people are old enough to enter a nightclub. The user enters the birthdate of a person into the app, and clicks a “Check” button. The app then calculates the user’s age based on the birthdate and stores it in a variable. If the person is 18 years of age or older, a message should be displayed that indicates they are allowed to enter the nightclub. If the user is less than 18 years old, a message should be displayed that says the person cannot enter the nightclub.

Task 2 – Introduction to MIT AppInventor MIT AppInventor is a web-based programming environment for developing Android apps. You can access it here: https://appinventor.mit.edu/. Click the Create Apps! Button in the top right corner to access AppInventor. The lab computers are set up with the Android emulator to test apps, but if you want to use your own laptop, follow this guide: https://appinventor.mit.edu/explore/ai2/setup.html There are two main views in AppInventor: the Designer view, which is used to design the user interface, and the Blocks view, which is where the program behaviour is defined. The images on Page 3 label the key components of both views. Over the first 6 weeks of this course, we will cover many of the user interface components and block types. The purpose of this lab is to become familiar with AppInventor environment. Please work through this tutorial: http://appinventor.mit.edu/explore/ai2/hello-codi.html

ITECH2000 – Module 2 Exercises

Page 2

The Designer View

The Blocks view

ITECH2000 – Module 2 Exercises

Page 3

Task 3 – Exploring the Simple Addition app By now you should know how to open MIT AppInventor, interact with the two main views (Designer and Blocks), import a project, and run it on the emulator. We will continue to explore AppInventor for the next few weeks, so don’t worry if you don’t understand everything just yet! Now it’s time to explore the Simple Addition program you looked at in Task 2. In the SimpleAddition.zip folder you downloaded earlier, you will see a file named SimpleAddition.aia. This is an AppInventor project file, which means that you can import it and run it in AppInventor. To do this, select the Projects menu and click Import project (.aia) from my computer …. Select the SimpleAddition.aia file and upload it. Spend some time exploring the project, and if you feel comfortable, try to modify some properties of the user interface elements in the Designer view. Run the program to see what changes. After you have spent some time exploring the project, try to export the project. Again, open the Projects menu and select Export selected project (.aia) to my computer. This is how you will download projects to submit assignments in ITECH2000.

Extension Task Modify the SimpleAddition app so that it will: • •

Work with subtraction, multiplication, or division. Calculate the result of three numbers instead of two (e.g. Number1 + Number2 x Number3).

Modify the pseudocode first to help you plan any changes that need to be made to the code blocks. You may need to read ahead to determine which blocks to use – or feel free to drag any block into the Viewer and see what happens!

ITECH2000 – Module 2 Exercises

Page 4

ITECH2000 Mobile Development Fundamentals Solutions to Module 2 Review Exercises Part 1 – Review Questions Q1. What is the differences between a Text Box and a Label? Whilst both are capable of displaying text, only the Text Box component allows the user to edit the text. The Label will not be editable. Also, the Label has no event blocks, whereas the Text Box has events to notify when it receives or loses focus. Also, the Label has no action blocks other than the set-value action blocks for properties, whereas the Text Box has two action blocks: one to HideKeyboard, and another to RequestFocus. Q2. What are some of the properties that are common to Text Box and Label components? The following properties are common to both components: BackgroundColour, FontSize, Height / HeightPercent, Text, TextColor, Visible, Width / WidthPercent The following are distinct to Text Box components: Enabled, Hint, Multiline, NumbersOnly The following are distinct to Label components: HasMargins Q3. What type of component can display a graphic that you have created in photoshop, paint, or other graphics editing program? The Image component Q4. What is meant by the term ‘event’ in terms of AppInventor? Give an example in relation to Button components. An event is an occurrence of something that the mobile device can detect, that we may wish to respond to. For example, the touching/clicking of a Button. Button components can respond to more nuanced actions – such as the touching and the releasing of the Button.

ITECH2000 – Module 2 Exercises

Page 5

Q5. What is an action block, in relation to components in AppInventor? Give an example in relation to the Label component. An action block is a block which can be placed into a sequence of code, which tells the computing device that it will need to do something when that point in the sequence is reached. They are blocks which have a cut-out near the left of the top edge of the block piece, and a protrusion directly underneath on the bottom edge of the block piece. In the case of the Label component, there are a range of action blocks for set-value actions regarding the properties of the Label component, for example:

Because the set-value action blocks require additional information, there is an extra cut-out which has a trapezoidal shape at the far-right edge, in this case the slot is named “to”. Q6. If each of the following were attached to the “to” slot of a ‘set lblOutput .Text to:’ block in turn, what would end up being displayed in the label on the screen of the app (in other words, what do they each evaluate to) ? a.

123ABC

[no spaces]

b. 6 c.

23 – the multiplication expression must be evaluated first, because it is part of the addition expression. d.

35 – this time the addition must be evaluated first, as it is one of the multiplication expression’s operands.

ITECH2000 – Module 2 Exercises

Page 6

Q7. Assume there is an app with three button components, named Button1, Button2, Button3, The following code blocks exist in the blocks editor view for the screen:

a. If only button 2 is visible when the app begins, can the user cause button 1 to become visible? If so, how? The only event that can occur is the Click event for button 2. Its code sequence will set the Visible property of the button named Button3 to be false. The value of False for the Visible property means that the component will not be visible, hence not clickable and unable to generate any Click events. Since there are no other events possible beside the Button2’s click event, there is no way to make Button1 or Button3 visible. b. If only button 3 is visible when the app begins, can the user cause button 2 to become visible? If so, how? Initially, the only possible event that can occur is Button3’s click. Looking at the Button3’s click event sequence, we see that it makes Button1 visible by setting the Visible property to true, thus enabling it for possible subsequent events. And looking at the Button1’s Click event, we can see that it will set the Visible property of the button named Button2 to be true, which would signify that the button becomes visible if it was not already visible. Hence, it is possible to make button2 visible.

Notes about writing AppInventor code by hand: • • •

Draw lines showing the extent and conclusion of all cradles. The content of the cradle should all be indented compared to the text that is part of the cradle-block itself. For any expressions inside of other expressions (such as in math expression blocks), wrap the contained expression in square brackets. Indicate that something is attached to another block, by using the colon after the name of the attachment point.

For example, the code provided for Button1 in question 7 would be written out in the following way: when Button1 . Click do: set Button2 . Visible to: true

ITECH2000 – Module 2 Exercises

Page 7

Q8. Write (by hand on paper) a code block sequence to fulfil the following requirements: There is a textbox named txtQuantityAdult into which the user will enter a number specifying how many adult-priced tickets to watch a movie they want to buy. There is a textbox named txtQuantityChild into which the user will enter a number specifying how many child-priced tickets to watch a movie they want to buy. There is a button named btnCalculate, which when clicked will report into a label named lblResult the phrase "Your purchase will cost " followed by the total cost of the tickets based on the following rates: adult tickets are $17 each, and child tickets are $11 each. The actual AppInventor code blocks that achieve the above, would be as follows (given that we have not yet learned about variables which are in the next module of this course):

To write this by hand, would look like the following: when btnCalculate . Click do set lblResult . Text to: join : “Your purchase will cost ” : [ txtQuantityAdult . Text × 17 ] + [txtQuantityChild . Text × 11 ]

Part 2 – AppInventor Programming Tasks Sample Solutions of the programming tasks will be made available on Moodle for you to import into AppInventor. Please study these and compare them to your own attempts.

ITECH2000 – Module 2 Exercises

Page 8

ITECH2000 Mobile Development Fundamentals Module 3 Review Exercises – Solutions Q1. Assume the following variables have been initialised as follows:

What would be the result and/or effect of evaluating each of the following sets of code blocks? a.

It would be the text value “North Shepparton” b.

It would be the numeric value 10

Q2. Assume there are two global variables named first and second. What would be the result and/or effect of evaluating each of the following sets of code blocks? a.

The calculation would be performed, and the result of evaluation will be set as the new value for the global variable named ‘first’. In this case, ‘first’ will be set to the value 35. b.

The calculation would be performed, and the result of evaluation will be set as the new value for the global variable named ‘second’. In this case, ‘second’ will be set to the value 23.

ITECH2000 – Module 2 Exercises

Page 9

c.

This is simply an expression of a subtraction – so calculation would be performed but nothing will happen to the result. In this case, the value of the global variable ‘first’ will be retrieved (which is 35, from answer A), and the value of the global variable ‘second’ will be retrieved (which is 23, from answer B), then the subtraction will occur, and so the result of evaluation will be 12.

Q3. If first currently contains the value 20, and second currently contains the value 5, what is the effect of executing the following code block sequence? (In other words, what will the values for first and second be after the conclusion of this sequence?)

The effect of the first line is to change the value remembered by/stored in the global variable named ‘second’, to have the same value as the global variable ‘first’ has, which is 20. The effect of the second line, is to change the value remembered by / stored in the global variable named ‘first’ to have the same value that at that point in time the global variable ‘second’ has, which due to the line before it, will be the value 20. (Since ‘first’ was already 20, this second line has no observable difference on the variable). The key point to note is that the sequence given above does not swap the values from each variable to the other. Q4. Consider the following sequence of code blocks:

a. What values will be stored for each of the local variables at the conclusion of the third ‘set’ block (i.e. after it has executed)? The variable ‘one’ will have become 4. The variable ‘two’ will have become 7. Due to the first of those, when ‘three’ is set, ‘one’ has the value 4, and so ‘three’ will have become 4.

ITECH2000 – Module 2 Exercises

Page 10

Observe that the values of ‘two’ and ‘three’ have effectively swapped (i.e. 7 is now in ‘two’ instead of ‘three’; and 4 is now in ‘three’ instead of ‘two’). b. If we duplicated the contents within the cradle of the outer block, so that the same three ‘set’ items were executed a second time, what would be the value store for each of the local variables after the second execution? Because the variable ‘two’ now has 7, the variable ‘one’ will have become 7. Also, because the variable ‘three’ now has 4, so the variable ‘two’ will have become 4. Due to the effect of ‘one’ becoming 7, now the variable ‘three’ will have also become 7 now. Observe that the values of ‘two’ and ‘three’ have effectively swapped from where they were at the conclusion of the answer for part A. (i.e. 4 is now in ‘two’ instead of ‘three’; and 7 is now in ‘three’ instead of ‘two’). This code sequence within the cradle shows how you would swap things. Usually we would name the ‘one’ variable something like ‘temporary’, as its role is to temporarily remember the value of one of the variables, while we copy the value of the other variable into the one where it previously was, before we now set that other variable to be what we temporarily were remembering.

Q5. Assume there is a textbox component named txtInputAge, and a label component name lblOutputMessage. The following is the code sequence for the Click event of a button named Button1:

Describe what will happen (if anything) when the user clicks on Button 1, when: a. the user has entered 50 into the textbox? We need to resolve the less-than expression’s left-hand expression and right-hand expression. The left-hand expression is a get-value block for a property of a textbox – the Text property, of the txtInputAge textbox. We are told that this will be 50. The right-hand expression is simply a literal number, 18. Thus the blue less-than expression can now be evaluated, using: 50 < 18 , which is false. Therefore, the ‘else’ expression will be evaluated to determine the value for using with the green ‘set’ block. The result of evaluating the ‘else’ expression is the text “Able to get a driver’s licence”, so that is what is set as the value for the Text property of the label named lblOutputMessage. b. the user has entered 10 into the textbox?

ITECH2000 – Module 2 Exercises

Page 11

We need to resolve the less-than expression’s left-hand expression and right-hand expression. As before, it will be the textbox’s Text property, which we are told that it is 10 The right-hand expression is once again simply a literal number, 18. The blue less-than expression will be evaluated using: 10 < 18 , which is true. Therefore, the ‘then’ expression will be evaluated to determine the value for using with the green ‘set’ block. The result of evaluating the ‘then’ expression is the text “Too young to get a driver’s licence”, so that is what is set as the value for the Text property of the label named lblOutputMessage.

c. the user has entered 18 into the textbox? As with the previous 2, the Textbox’s text property is to be resolved, and we are told this is 18. And the right-hand part is still simply the literal value 18. So the blue less-than expression to be evaluated is: 18 < 18 , which is false (because this is a strict less-than, not a less-than-or-equal-to). So the rest of the reasoning is as for answer A. d. the user has entered the word ‘cabbage’ into the textbox? We need to resolve the less-than expression’s left-hand expression and right-hand expression. As before, it will be the textbox’s Text property, which we are told that it is the letters spelling ‘cabbage’. The right-hand expression is once again simply a literal number, 18. The computer/phone will attempt to evaluate the blue less-than expression, i.e. it will attempt to evaluate the following: “cabbage” < 18 . It cannot do this, because it doesn’t know how to compare a number with text, and this causes an error. AppInventor in the browser will display an error message; the app running on the phone or emulator will appear to not do anything, except possibly also show the error message.

Q7. What value will the variable ‘mystery’ have after each of the following sequence of code blocks has executed? a.

We first need to resolve the blue relational expression’s left- and right-hand sides. The left-hand side is an expression consisting of a get-value block for the variable ‘one’.

ITECH2000 – Module 2 Exercises

Page 12

This evaluates to the current value of the variable, which at tha...


Similar Free PDFs