• No results found

itf%&^\^j ' 5 ^' if^'i-sm'a 4-'i, "! PEARSON

N/A
N/A
Protected

Academic year: 2021

Share "itf%&^\^j ' 5 ^' if^'i-sm'a 4-'i, "! PEARSON"

Copied!
7
0
0

Loading.... (view fulltext now)

Full text

(1)

STARTING OUT WITH

x^i^^'n^-AJ itf%&^\^J ' 5 ^'•if^'i-sM'A 4-'i, "!•

-

, S L

feMl£ J-L J CO Hi

Tony Gaddis

and

Rebecca Halsey

PEARSON

Boston Columbus Indianapolis New York San Francisco

UpperSaddleRiver Amsterdam CapeTown Dubai London Madrid Milan Munich Paris Montreal Toronto Delhi MexicoCity SaoPaulo Sydney

Hong Kong Seoul Singapore Taipei Tokyo

(2)

Chapter

1 Introduction to

Programming

and

App

Inventor 25

1.1 Introduction 25

1.2 WhatIsaComputer Program? 28

1.3 Introducing App Inventor 32

TUTORIAL 1-1: Starting AppInventorand Creatinga

NewProject 32

1.4 GettingHands-On with App Inventor 46

tutorial 1-2: Creatingthe Screen for the Hello WorldApp 61

tutorial 1-3: Completing the Hello WorldApp 75

tutorial 1-4: Creatingthe Good MorningTranslatorApp 79

ReviewQuestions 88

Chapter

2

Working

with Media 97

2.1 Displaying Images 97

tutorial 2-1: Changingthe Screen'sBackgroundImage 100

tutorial2-2: Switchingthe Screen'sBackground Image

in Code 104

tutorial 2-3: UsingtheImageComponent 109

tutorial2-4: CreatingtheFlags App 114

2.2 Duplicating Blocks and Using Dropdowns 120

2.3 Sounds 123

tutorial 2-5: Creatingthe Guitar App 126

tutorial 2-6: Makingthe Phone Vibrate 130

2.4 Color Blocks 133

2.5 Layout Components 136

tutorial 2-7: Using Layout Components andColor Blocks 140

2.6 Commenting Blocks 143

tutorial 2-8: AddingComments 144

ReviewQuestions 145

7

(3)

8 Contents

Chapter

3

Input, Variables,

and Calculations 153

3.1 The TextBoxComponent 153

3.2 Performing Calculations 159

TUTORIAL 3-1: CalculatingFuelEconomy 162

TUTORIAL 3-2: Creatingthe RestaurantTipCalculatorApp 168

3.3 StoringDatawith Variables 173

TUTORIAL 3-3: Creatingthe KilometerConverterApp 182

TUTORIAL 3-4: CreatingtheChange CounterApp 193

3.4 Creating Blocks withTypeblocking 198

3.5 The SliderComponent 200

3.6 Math Functions 204

ReviewQuestions 206

Chapter

4 Decision Blocks and Boolean

Logic

211

4.1 Introductionto Decision Blocks 211

4.2 Relational Operators and the ifBlock. 216

tutorial 4-1: TheTestAverage App 218

4.3 The if then else Block 226

tutorial4-2: ModifyingtheTestAverageApp 227

tutorial 4-3: Creating theWages App 229

4.4 A FirstLookAtComparing Strings 236

4.5 Logical Operators 237

tutorial 4-4: Creating the RangeCheckerApp 240

4.6 Nested Decision Blocks 242

tutorial 4-5: Creatingthe GraderApp 243

4.7 The if then else if Block 245

4.8 Workingwith Random Numbers 248

tutorial 4-6: Simulating Coin Tosses 250

4.9 The Screen's initialize Event 253

4.10 The ListPickerComponent 254

tutorial 4-7: Creatingthe Time ZoneApp 256

4.11 The CheckBoxComponent 259

ReviewQuestions 265

Chapter

5

Repetition Blocks,

Times, and Dates 271

5.1 The Notifier Component 271

5.2 Thewhile Loop 279

TUTORIAL 5 1: TheEndingBalanceApp 282

5.3 The for each Loop 287

tutorial 5-2: Calculatinga Sumof Consecutive Numbers 291

5.4 TheClockComponent 294

tutorial5-3: Creatinga Clock App 297

(4)

5.5 The DatePickerComponent 303

Review Questions 306

Chapter

6 Procedures and Functions 311

6.1 ModularizingYour Code With Procedures 311

6.2 Procedures 312

tutorial6-1: CreatingtheLights App ' 316

6.3 Passing ArgumentstoProcedures 322

tutorial6-2: Creatingthe AreaCircle App 327

6.4 ReturningValues From Procedures 331

tutorial 6-3: TheCupsTo OuncesApp 334

ReviewQuestions 338

Chapter

7 Lists 343

7.1 Creating a List 343

TUTORIAL 71: CreatingaList 345

7.2 Iterating Over aList with thefor each Loop 350

TUTORIAL 7-2: IteratingOver aListwith thefor eachLoop 353

7.3 Selecting an Item 356

tutorial 7-3: SelectinganItem ina List 356

TUTORIAL 7-4: Usingthelength of list Function 361

7.4 Inserting andAppending Items 365

tutorial 7-5: AddItemstoaList 367

7.5 Removing Items 372

7.6 Replacing Items 374

tutorial 7-6: ReplacingandRemovingList Items 376

7.7 Searchingforan Item 384

tutorial7-7: CreatingaNumber-GuessingGame 385

7.8 Other List Functions 390

Review Questions 391

Chapter

8

Storing

Data on the Device 395

8.1 App Inventor Storage Components 395

8.2 TheApplication Sandbox 396

8.3 FileComponent 396

tutorial8-1: Creatinga File 399

8.4 Retrieving a File 402

TUTORIAL8-2:Retrievinga File 402

tutorial 8-3: AppendingaFile 405

8.5 TinyDB 407

8.6 Tag-Value Pairs 408

8.7 Storing aTag-ValuePair 409

(5)

10 Contents

tutorial 8-4: StoringNames and Phone Numbers 409

8.8 Retrievinga Value 410

tutorial 8-5: Storingand RetrievingValues 411

8.9 Tag-ValuePairs when the Value isa List 413 tutorial 8-6: Storinga Listas aValue in aTag-ValuePair 414

8.10 TinyDBAcross MultipleScreens 421

TUTORIAL 8-7: TinyDBacross MultipleScreens 423

ReviewQuestions 433

Chapter

9

Graphics

and Animation 439

9.1 The Canvas Component 439

tutorial 9-1:Drawingon the Canvas 442

9.2 The Ball and ImageSprite Component 448

tutorial 9-2:BouncingBall 448

tutorial 9-3: Fishbowl- Using theImageSprite Component 456

9.3 Usingthe ClockComponentto Create Animations 458

tutorial 9-4: Crack the Egg 458

9.4 Dragging Sprites 463

tutorial 9-5: Drag BallSpriteExample 463

tutorial 9 6: Drag the Ballinto the Box 464

9.5 DetectingCollisions 469

tutorial 9-7: PoppingBalloons 471

ReviewQuestions 479

Chapter

10

Working

with Text 485

10.1 Concatenating Strings 485

10.2 Comparing Strings 491

tutorial10-1: Comparing Strings 494

10.3 Trimming a String 499

10.4 Converting Case 500

tutorial10-2: Trim and Convertto FormatTags 501

10.5 Finding aSubstring 505

tutorial 10-3: ValidateanEmail Address 508

10.6 Replacinga Substring 513

10.7 Extracting a Substring 513

10.8 Splittinga Substring 515

tutorial 10-4: Validating Email-Valid Name andTop-LevelDomain ... 519

ReviewQuestions -529

Chapter

11 Text to

Speech

and Text

Messaging

533

11.1 TheTextToSpeech Component 533

tutorial il l: Textto Speech 536

(6)

11.2 TheTexting Component 540

11.3 ReceivingTextMessages 543

tutorial n-2: Creatingthe Speak Messagesfrom FamilyApp 544

11.4 Sending Text Messages 547

tutorial 113: ReplytoFamily 548

ReviewQuestions 550

Chapter

12 Sensors 555

12.1 The LocationSensor 555

tutorial 12-1: DisplayLocation 559

12.2 The OrientationSensor 566

tutorial12-2: Cat and Mouse 569

12.3 The Accelerometer 574

TUTORIAL 12-3: ShaketoClear Canvas 576

12.4 Using theActivityStarter Componentto launch Google Maps 578

tutorial 12-4: Open Google Maps 580

ReviewQuestions 581

Chapter

1 3 Other

App

Inventor

Capabilities

585

13.1 RecordingAudio 585

tutorial 13-1: Record andPlayBackAudio 587

13.2 Taking a Photo with the Phone's Camera 591

13.3 The Camcorder Component 592

13.4 Using the ImagePicker Component 593

tutorial 13-2: UsingtheImagePicker 593

13.5 PlayingVideo 596

tutorial 13-3: PlayingVideo 597

13.6 Selecting Contacts from theContact List and Placing PhoneCalls... 600

tutorial 13-4: Usingthe Contact and Phone Number Pickers 601

tutorial 13-5: Usingthe PhoneCallcomponent 604

13.7 Scanning a Barcode 608

13.8 Using VoiceRecognition 609

tutorial 13-6: Speak aTextMessage 609

13.9 Connecting to aTwitterAccount 613

tutorial 13-7: BuildingaTwitterApplication 614

13.10TinyWebDB 616

ReviewQuestions 617

Appendix

A

Setting Up App

Inventor 621

Appendix

B

Connecting

an Android Device to

App

Inventor 627

(7)

12 Contents

Appendix

C

Uploading

Your

Application

to

App

Inventor

Gallery

and

Google Play

Store 637

Appendix

D

Component

Reference 643

Appendix

E Answers to

Checkpoints

673

Index 685

References

Related documents

However, if an organisation has a culture open to learning, this makes it easier to change human resources development practices, such as devolving responsibility

Nossos resultados mostraram que ainda são necessárias novas investigações para melhor compreensão dos receptores envolvidos na ingestão dos parasitos pelas células do

On the other hand, when the attached graphs are paths, we obtain results for the distance matrix of the tree associated with a basic feasible solution of a transportation problem..

We have reviewed the interim condensed consolidated financial statements, comprising the consoli- dated statement of financial position, the consolidated income statement,

1 Bernard Beckerman, Shakespeare at the Globe, 1599-1609 (New York: Macmillan, 1962); Roslyn Lander Knutson, The Repertory of Shakespeare’s Company, 1594-1613 (Fayetteville:

Amsterdam Cape Town Dubai London Madrid Milan Munich Paris Montreal Toronto Delhi Mexico City Sao Paulo Sydney Hong Kong Seoul Singapore

We followed the approach used in the international sample, as described in detail elsewhere [ 22 , 23 ]. Data were analysed using PASW 18 software. Item scores on the “bothered”

To sum up, it is the aim of the dissertation to shed light on the possibilities to encounter the shortage of skills in the ICT-industry which are to analyze the career choices