alice programming l.
Download
Skip this Video
Download Presentation
Alice Programming

Loading in 2 Seconds...

play fullscreen
1 / 15

Alice Programming - PowerPoint PPT Presentation


  • 618 Views
  • Uploaded on

Alice Programming . Chapter 4 Classes, Objects, Methods and Parameters. Class. A Class defines a particular kind of object In Alice, they are predefined as 3D models Class names begin with a capital letter When an object is created this is called instantiating the class

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'Alice Programming' - Melvin


Download Now An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
alice programming

Alice Programming

Chapter 4

Classes, Objects, Methods and Parameters

class
Class
  • A Class defines a particular kind of object
  • In Alice, they are predefined as 3D models
  • Class names begin with a capital letter
  • When an object is created this is called instantiating the class
  • This is because instantiating the object creates an instance of that class
objects
Objects
  • Objects are instances of a class
  • Object names begin with lowercase letters
  • For example, spike is the object from the class named Dog
  • mary is the name of the object from the class named Person
  • We can have an unlimited number of objects from the same class (we can have several snowmen each with different names)
methods
Methods
  • A method is a sequence of instruction that complete a particular task.
  • Alice has many built-in methods for each class. These are called primitive methods.
  • Methods divide a program into small, manageable pieces that work together to create a meaningful whole.
methods5
Methods
  • Some methods need to be sent certain pieces of information in order for them to work correctly.
  • A move method needs to told in which direction to move.
  • Parameters are used to hold specific items of information that are then passed to a method.
creating your own methods
Creating your own methods
  • In Alice, you can define methods for an object acting along.
  • You can also define a method for two or more objects interacting with one another.
  • Methods that specifically reference more than one object are world-level methods.
  • Methods that define a behavior for a single object are called class-level methods.
creating your own methods7
Creating your own methods
  • Methods are “called”. This causes the instructions in the method to be run.
stepwise refinement
Stepwise Refinement
  • Storyboards break down our animations into scenes.
  • We need to also break down each overall task into it’s individual steps
  • This is called stepwise refinement
our experience with alice
Our Experience with Alice
  • Up until now, we’ve been writing all of our code in the World.my first method block.
  • Our code just seemed to grow and grow as we added new instructions.
  • To continue on this path would mean that by project time, our programs would be hundreds of line long.
  • Instead, we need to learn to break our code down into methods which we will then call.
revised storyboard for first encounter
Revised Storyboard for First Encounter

Do in order

surprise – spiderRobot and alienOnWheels surprise each other

investigate – spiderRobot gets a closer look at alienOnWheels

react – alienOnWheels hides and spiderRobot sends a message

now we need to break down each major task of our storyboard
Now we need to break down each major task of our storyboard

surprise

Do in order

alien moves up

alien says “Slithy toves?”

robot’s head turns around

now we need to break down each major task of our storyboard12
Now we need to break down each major task of our storyboard

investigate

Do in order

robot turns to look at alien

Do together

robot moves forward (toward the alien)

robot’s legs walk

now we need to break down each major task of our storyboard13
Now we need to break down each major task of our storyboard

react

Do in order

alien moves down

robot turns to look at the camera

robot’s head turns red (to signal danger)

robot says “Houston, we have a problem!”

world level methods
World-level methods
  • This is an example of a world-level method.
  • More than one object is manipulated in the method.
  • Turn to page 77 in your Alice text and let’s design and call these three methods, surprise, investigate, and react
ad