DOC PREVIEW
TRINITY CSCI 1311 - Properties and Functions
Pages 7

This preview shows page 1-2 out of 7 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 7 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 7 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 7 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

1Properties and Functions9/12/20072Opening Discussion■Let's look at some solutions to the interclass problem.■What are variables? What do they enable us to do?■What are parameters? What do they enable us to do?■I have moved back the due date on the project ideas so you will have a better idea of what you are capable of in Alice.■The online grades are available now. User your regular username and your starting password is your 7-digit TU ID number.3Scope■When we create a variable or a parameter in Alice it exists just in the method we create it in.■The segment of code a variable/parameter can be used over is called its scope. This type of scope is called local scope. In Alice this is fairly intuitive, but the same concept carries to other programming languages.■You can make variables in two different methods with the same name and they have no relationship to one another.4Properties■Sometimes you want variables with a larger scope so they can be accessed across multiple methods.■Alice allows you to add properties to objects to get this type of behavior.■A property is basically a variable that is stored in one of the objects. Like method variables you can pick the type and give it an initial value.■Each different object, even copies of the same class of object, can have a different value for their properties.■Let's set up a scene where two characters “race” and the user picks who wins by setting a property in each telling it how far to move.5Vehicles■There are many situations where you want to movement of one object to impact another.■For example, if one object is sitting or standing on another object, moving the supporting object should move the supported on as well.■We could do this with doTogether moving things at the same time, but Alice provides a simpler method with the vehicle property.■Whenever the vehicle of an object moves, that object will move along with it.6Functions■We have already been creating methods for objects to give them different behaviors. We can also add functions to objects when there are things we need to calculate for a particular object.■The difference between a method and a function is that the function returns a value to us. Methods don't. They generally just do something to change objects in the world.■Functions can be given parameters and variables just like methods.7Minute Essay■Do you have any questions about variables, parameters, properties, or functions? Next class we will press on into flow control. That is where the logic part of this class begins to come into play.■Interclass Problem – Do one of the following: problem 3.8, 3.9, or


View Full Document

TRINITY CSCI 1311 - Properties and Functions

Course: Csci 1311-
Pages: 7
Documents in this Course
Arrays

Arrays

12 pages

Arrays

Arrays

10 pages

Applets

Applets

5 pages

Arrays

Arrays

8 pages

Methods

Methods

12 pages

Drawing

Drawing

8 pages

Load more
Download Properties and Functions
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Properties and Functions and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Properties and Functions 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?