Uploaded on

 

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
261
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
1
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. About the Presentations •  The presentations cover the objectives found in the opening of each chapter. •  All chapter objectives are listed in the beginning of each presentation. •  You may customize the presentations to fit your class needs. •  Some figures from the chapters are included. A complete set of images from the book can be found on the Instructor Resources disc. 1
  • 2. An Introduction to Programming Using Alice 2.2, Second Edition Chapter 1 An Introduction to Alice and Object-Oriented Programming
  • 3. Objectives After finishing this chapter, you should be able to: •  Provide a brief definition of the following terms: –  Algorithm, computer program, object, property, method, state of an object, object-oriented programming (OOP), computer programming language, Integrated Development Environment (IDE), function, event, class, instance, instantiation, and method parameter An Introduction to Programming Using Alice 2.2, Second Edition 3
  • 4. Objectives (cont’d.) •  Run the Alice software and locate and describe the following components of the Alice interface: –  World window, Object tree, Details area, Editor area, Events area, menu bar, Trash can icon, Clipboard icon, Play button, Undo button, and Redo button •  Load and play an existing Alice world An Introduction to Programming Using Alice 2.2, Second Edition 4
  • 5. Objectives (cont’d.) •  Create a new Alice world by adding objects to a blank world, positioning them, and using simple methods to animate those objects •  Print the code for Alice methods and events •  Save an Alice world as a QuickTime movie file (*.mov) An Introduction to Programming Using Alice 2.2, Second Edition 5
  • 6. An Introduction to Programming Using Alice 2.2, Second Edition 6 Object-Oriented Programming and Alice •  Algorithm –  A step-by-step process •  Methods –  Programs that manipulate the properties of an object •  Object –  Collection of properties along with the methods that are used to manipulate those properties •  State of an object –  Values stored in the properties of an object at any given time
  • 7. An Introduction to Programming Using Alice 2.2, Second Edition 7 Tutorial 1A – Exploring the Alice Interface •  Start the Alice software –  Integrated Development Environment (IDE) •  Computer program that is used to write other computer programs •  Welcome to Alice! dialog box has five tabs –  Tutorial, Recent Worlds, Templates, Examples, and Open a world •  Click the Tutorial tab and you will see four Alice tutorials
  • 8. 8An Introduction to Programming Using Alice 2.2, Second Edition
  • 9. An Introduction to Programming Using Alice 2.2, Second Edition 9 Tutorial 1A – Exploring the Alice Interface (cont’d.) •  Click the Recent Worlds tab –  You will see thumbnail sketches of the most recently saved Alice worlds •  Click the Templates tab –  Templates for starting a new virtual world - dirt, grass, sand, snow, space, and water •  Click the Examples tab –  Example worlds created by the Alice developers are provided
  • 10. An Introduction to Programming Using Alice 2.2, Second Edition 10 Tutorial 1A – Exploring the Alice Interface (cont’d.) •  Click the Open a world tab –  Tab is used to access Alice worlds saved on your computer •  Click the Examples tab –  Click the lakeSkater thumbnail –  Click the Open button to open the lakeSkater Alice world
  • 11. 11An Introduction to Programming Using Alice 2.2, Second Edition
  • 12. 12An Introduction to Programming Using Alice 2.2, Second Edition
  • 13. An Introduction to Programming Using Alice 2.2, Second Edition 13 Tutorial 1A – Exploring the Alice Interface (cont’d.) •  The main work areas of the Alice interface –  The World window •  Contains a view of the lakeSkater virtual world •  Set of blue arrows below the window controls the Alice camera –  The Object tree •  Appears to the left of the World window •  Shows the objects in the current Alice world organized as a tree of tiles
  • 14. Tutorial 1A – Exploring the Alice Interface (cont’d.) •  The main work areas of the Alice interface (cont’d.) –  The Details area •  Located below the Object tree •  Has tabs to show properties, methods, and functions for the currently selected Alice object •  Function: method that returns a value, such as the distance between two objects –  The Editor area •  Largest area of the Alice interface An Introduction to Programming Using Alice 2.2, Second Edition 14
  • 15. Tutorial 1A – Exploring the Alice Interface (cont’d.) •  The main work areas of the Alice interface (cont’d.) –  The Events area •  Above the Editor area •  Shows existing events and is used to create new events •  Event: consists of a condition, called an event trigger, and a method, called an event handler An Introduction to Programming Using Alice 2.2, Second Edition 15
  • 16. Tutorial 1A – Exploring the Alice Interface (cont’d.) •  Other elements of the Alice interface –  Trash can icon and the Clipboard icon are used for editing –  Undo and Redo buttons •  Useful for editing an Alice world –  Play button is used to play an Alice world •  Menus –  Alice interface has a menu bar at the top of the screen with four menus: File, Edit, Tools, and Help An Introduction to Programming Using Alice 2.2, Second Edition 16
  • 17. An Introduction to Programming Using Alice 2.2, Second Edition 17 Tutorial 1B – Playing an Alice World •  Buttons near the top of the Alice interface –  Play, Undo, and Redo •  Click the Play button to watch the show unfold •  New window has a speed slider control and five buttons across the top of the window –  Pause –  Play –  Restart –  Stop –  Take Picture
  • 18. 18An Introduction to Programming Using Alice 2.2, Second Edition
  • 19. Tutorial 1B – Playing an Alice World •  The Restart button –  Used to begin playing the current world again from the beginning –  The Pause and Play buttons work like the pause and play buttons on a DVD player –  Click the Restart button –  Experiment with the Pause and Play buttons An Introduction to Programming Using Alice 2.2, Second Edition 19
  • 20. Tutorial 1B – Playing an Alice World (cont’d.) •  Speed slider –  Used to change the speed of the world while it is playing –  Restart the world, and experiment with the speed slider control •  Take Picture button –  Captures an image of the currently playing world and saves it in a data file –  Restart the world and click the Take Picture button to take a picture of the world An Introduction to Programming Using Alice 2.2, Second Edition 20
  • 21. Tutorial 1B – Playing an Alice World (cont’d.) •  Stop button –  Stops the world that is currently playing and returns you to the standard Alice interface –  Once pressed, you will need to click the standard interface’s Play button to replay the world An Introduction to Programming Using Alice 2.2, Second Edition 21
  • 22. An Introduction to Programming Using Alice 2.2, Second Edition 22 Tutorial 1C – Creating Your First Alice World •  Start the Alice software •  In the Welcome to Alice! dialog box, click the Templates tab •  Thumbnail sketches for the six new world templates –  Dirt, grass, sand, snow, space, and water
  • 23. 23An Introduction to Programming Using Alice 2.2, Second Edition
  • 24. 24An Introduction to Programming Using Alice 2.2, Second Edition
  • 25. Tutorial 1C – Creating Your First Alice World (cont’d.) •  Adding objects to an Alice world –  Click the large green ADD OBJECTS button in the bottom-right corner of the World window –  Note that the Alice interface now looks different –  Scene Editor •  Has new controls, a larger World window, and object galleries on the bottom •  Replaces the Events area and the Editor area when you are in Scene Editor mode An Introduction to Programming Using Alice 2.2, Second Edition 25
  • 26. 26An Introduction to Programming Using Alice 2.2, Second Edition
  • 27. An Introduction to Programming Using Alice 2.2, Second Edition 27 Tutorial 1C – Creating Your First Alice World (cont’d.) •  Adding objects to an Alice world (cont’d.) –  Explore the galleries before preparing to add objects to your new world •  Click the folder icon on the gallery navigation bar to move up one level in the tree of galleries •  Click the Local Gallery icon to go back to the Local Gallery •  Find and click the Animals folder icon to open the folder
  • 28. An Introduction to Programming Using Alice 2.2, Second Edition 28
  • 29. An Introduction to Programming Using Alice 2.2, Second Edition 29 Tutorial 1C – Creating Your First Alice World (cont’d.) •  Object classes and instances in Alice –  Class •  Group of objects with the same properties and the same methods –  Objects in the same class •  Virtually identical to each other •  Values stored in some properties may be different –  Instance of the object •  Each copy of an object from a particular class
  • 30. An Introduction to Programming Using Alice 2.2, Second Edition 30 Tutorial 1C – Creating Your First Alice World (cont’d.) •  Object classes and instances in Alice (cont’d.) –  To instantiate a Bunny class object •  Click the Class Bunny icon •  Click the Add instance to world button to put a bunny into the world •  Add an object to an Alice world by clicking an object class tile and dragging it into place in the World window •  You should now have an Alice world with two objects - a bunny and a chicken
  • 31. 31An Introduction to Programming Using Alice 2.2, Second Edition
  • 32. An Introduction to Programming Using Alice 2.2, Second Edition 32 Tutorial 1C – Creating Your First Alice World (cont’d.) •  Positioning objects –  Layout tools can be used to manipulate objects –  Pointer tool is already selected •  Experiment a bit by using the pointer to click the bunny and move it around the screen –  Click the Rotate tool and try turning the bunny a few times –  Before exiting Scene Editor mode •  Properly position the bunny in its starting position for the new Alice world you are creating
  • 33. 33An Introduction to Programming Using Alice 2.2, Second Edition
  • 34. 34An Introduction to Programming Using Alice 2.2, Second Edition
  • 35. Tutorial 1C – Creating Your First Alice World (cont’d.) •  Positioning objects (cont’d.) –  After the bunny is in position, click the large green DONE button to close the Scene Editor •  Adding some action –  Click the World tile in the Object tree in the upper-left corner of the interface –  Click the methods tab in the Details area –  Click the bunny tile in the Object tree –  Make sure methods tab is selected in the Details area •  Find and drag the bunny move tile into the middle of world.my first method An Introduction to Programming Using Alice 2.2, Second Edition 35
  • 36. 36An Introduction to Programming Using Alice 2.2, Second Edition
  • 37. Tutorial 1C – Creating Your First Alice World (cont’d.) •  Adding some action (cont’d.) –  Select forward for the direction, and then 1 meter for the amount –  To test your world, click the Play button –  To change the amount the bunny moves, click the 1 meter parameter in the move tile in your new method •  Choose one of the values in the drop-down menu An Introduction to Programming Using Alice 2.2, Second Edition 37
  • 38. Tutorial 1C – Creating Your First Alice World (cont’d.) •  Adding some action (cont’d.) –  Find the bunny turn to face method tile •  Parameter - object you want the bunny to face •  Drag the bunny turn to face tile into the Editor area •  Choose camera as the object you want the bunny to face An Introduction to Programming Using Alice 2.2, Second Edition 38
  • 39. •  Adding some action (cont’d.) –  Add two tiles to make the bunny speak, then save the world –  Find and drag the bunny say tile into the Editor area and drop it below your other two instructions –  When the parameter menu appears, click other, and then type Hello, World! An Introduction to Programming Using Alice 2.2, Second Edition 39 Tutorial 1C – Creating Your First Alice World (cont’d.)
  • 40. •  To add another instruction and save your world: –  Add another bunny say tile to make the bunny say “Hello, Dr. Kernighan!” –  Play your world again –  To save the world you created •  Click the File menu and then click Save World –  Decide where you want to save the world –  Type the name hello world, with no punctuation, in the File name box An Introduction to Programming Using Alice 2.2, Second Edition 40 Tutorial 1C – Creating Your First Alice World (cont’d.)
  • 41. 41An Introduction to Programming Using Alice 2.2, Second Edition
  • 42. Tutorial 1C – Creating Your First Alice World (cont’d.) •  Closing and reloading a saved world –  Click File on the menu bar, and then click Exit –  Reopen the Alice software –  Click the Recent Worlds tab in the Welcome to Alice! dialog box –  Open the hello world world that you created An Introduction to Programming Using Alice 2.2, Second Edition 42
  • 43. Tutorial 1D – Printing Code From an Alice World •  Click File on the menu bar –  Use Export Code For Printing •  Notice that you need to tell the computer what to print –  Make sure that the boxes in front of both items are checked •  Tell Alice where you want to save the HTML file •  Add your name as the author of the code •  Click the Export Code button to create the new HTML document An Introduction to Programming Using Alice 2.2, Second Edition 43
  • 44. 44An Introduction to Programming Using Alice 2.2, Second Edition
  • 45. An Introduction to Programming Using Alice 2.2, Second Edition 45 Tutorial 1E – Saving an Alice World as a Movie File •  Start Alice, and open the hello world Alice world that you created in Tutorial 1C •  Click the Play button •  Click the Restart button if you wish to view the world again •  Click File on the Menu bar –  Then click the Export Video option •  Click the Save button to save the world
  • 46. An Introduction to Programming Using Alice 2.2, Second Edition 46 Tutorial 1E – Saving an Alice World as a Movie File (cont’d.) •  Type the name of your movie file in the File name box •  Click the Record button to start recording –  Click the Stop Recording button to finish recording •  Export the recorded video to a file •  Click the Stop button to close the window –  Close the Alice software
  • 47. 47An Introduction to Programming Using Alice 2.2, Second Edition
  • 48. An Introduction to Programming Using Alice 2.2, Second Edition 48 Summary •  Algorithm –  Step-by-step process •  Computer programs are algorithms •  Most modern computer programming languages are object-oriented languages •  Object –  Collection of properties and methods that can be used to manipulate those properties
  • 49. An Introduction to Programming Using Alice 2.2, Second Edition 49 Summary (cont’d.) •  State of the object –  Values stored in the properties of the object at any given time •  Class of objects –  Collection of all objects that have the same properties and methods •  Instance of that class –  Each individual object in a class
  • 50. Summary (cont’d.) •  Alice uses an object-oriented style of programming •  Alice makes it easier to learn programming because: –  It requires minimal memorization of syntax and it provides visualization and rapid feedback An Introduction to Programming Using Alice 2.2, Second Edition 50