Download presentation
Presentation is loading. Please wait.
1
Programming Logic Alice
2
Programming Implementation in Alice
3
Program Style Change program display styles in Preferences
How to access Preferences dialog box Click the Edit menu Click the Preferences choice Selecting a display style in Preferences dialog Click next to “display my program” in General tab Select a style Style recommended for course: Java Style in Color
4
Program Style (continued)
5
Adding Objects to Alice
Class: blueprint for an object How to populate Alice world with objects Click Add Objects button in world window Locate class specifying the object in the Alice Gallery Right-click class and select “Add instance to world” Objects in sample world: aliceLiddell and whiteRabbit Naming conventions for objects and classes Class: capitalize all words; e.g., AliceLiddell Object: capitalize all but first word; e.g., aliceLiddell Objects can be renamed from the object tree
6
Adding Objects to Alice (continued)
7
Accessing Object Subparts
Bounding box: encloses any Alice object Impact of selecting an object in the object tree Bounding box is drawn around object in world window Details area adapts to the selected object First action to program: Alice turns head to user First set of programming steps Select + sign next to aliceLiddell in object tree Select + sign next to neck subpart Select head (bounding box is drawn, details change) Drag doInOrder control to top of editing window
8
Accessing Object Subparts (continued)
9
Accessing Object Subparts (continued)
10
Sending Messages Programs rely on sending messages to objects
Method: behavior-producing message Programming Alice’s head to turn Select Alice Liddell’s head in the object tree Scan through the methods in the details area Click on pointAt() Drag pointAt()to the editing area and drop it Specify camera as the target
11
Sending Messages (continued)
12
Testing and Debugging Bug: error interfering with normal program functions Debugging: process of removing program bugs Click the Play button to test Alice Liddell application Alice Liddell’s head will turn toward the user
13
Testing and Debugging (continued)
14
Coding the Other Actions
say() message Displays dialog for an object Text can be customized by selecting other… Task: complete first Alice Liddell application Add Alice Liddell’s initial greeting Point the white rabbit to the user Have Alice Liddell introduce herself Have the white rabbit introduce himself Customize messages by selecting from more… Example: adjust fontSize of message text to 30
15
Coding the Other Actions (continued)
16
Statements Statement: a line or control structure in a program
Computer program is a collection of statements Basic format of a line in a program object.message(value); more... Control structures manage other statements Example: doInOrder contains other statements
17
The Final Action Sequential execution
Actions are performed consecutively Example: actions executed in doInOrder structures Simultaneous execution Actions are performed in parallel Example: actions performed in doTogether structure Finishing the first program Add doTogether control structure to application Send say( )to aliceLiddell and whiteRabbit Message value: Welcome to our world
18
The Final Action (continued)
19
Final Testing First set of actions are performed separately
Final actions are performed simultaneously
20
Final Testing (continued)
21
Questions
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.