Alice programming
Download
1 / 15

Alice Programming - PowerPoint PPT Presentation


  • 614 Views
  • Updated 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


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 l.jpg

Alice Programming

Chapter 4

Classes, Objects, Methods and Parameters


Class l.jpg
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 l.jpg
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 l.jpg
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 l.jpg
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 l.jpg
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 l.jpg
Creating your own methods

  • Methods are “called”. This causes the instructions in the method to be run.


Stepwise refinement l.jpg
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 l.jpg
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 l.jpg
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 l.jpg
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 l.jpg
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 l.jpg
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 l.jpg
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