Presentation is loading. Please wait.

Presentation is loading. Please wait.

Alice Variables Pepper.

Similar presentations


Presentation on theme: "Alice Variables Pepper."— Presentation transcript:

1 Alice Variables Pepper

2 Set to Java look Edit / preferences restart

3 Homework process Email pepper@adelphi.edu if it was not Okay for you
Need to be learning in addition to handing in work

4 What you should be learning
Project process – design, code, test Line by line flow of a program, dipping into and back from methods and functions Methods Types – world, object Calling method vs Defining method Why to use (break, teach, reuse)

5 More to know Use functions Answers a question Returns value
Match to the type of value (The method did not return a value.)

6 Know about variables boxes hold certain type of data
Can be set and changed When used, will have the value at a moment in time. Little quiz

7 Local Variable What: A box that holds a value the method can see and change on each run How to create: Click create new variable on right How to set: drag down to become a green line How to use: drag on top of a value of the same type Why:

8 Local Variable - Why Can change once and control more than one result - helped some people play with results to make a smooth movie Can get input from user or random value to put into value Can do calculations on that value If you know there will never be a change, less value to a variable Making something a number instead of a variable is called hard coding

9 Parameters What: Give control outside method
How to create: Click the create new parameter button How to set initially: give a value in the calling method How to reset: drag down to become a green line How to use: drag on top of a value of the same type WHY?

10 Why Parameters Help you reuse methods
Ex: Let the situation control how high to jump The one making the method does not need to know value, but must code for all possible values

11 Coming objectives Asking user for input Create functions
Property variables Extra - read in book movement vehicle

12 Practice Review: My rule for my dancer: This dancer always spins right twice as much as left. One scene with one dancer Dancer spin right 2 times Dancer spin left 1 time Dancer move forward 1 meter

13 Practice review Note the use of parameters. Does your spin method have parameters? I changed my mind, make it 14 times right and 7 times back - how did a variable help that?

14 Practice review change 2
Add the dancer asks how many times to spin and then spins the number you tell her forward that many and back ½ as many Could you do this without a variable? Show how to set a variable as the answer to a question. (First set, then drag world question function - note using a function)

15 Practice Review 2 solution
Which is the calling method here? Which is the called method? What is being returned from the method? What is being returned from the say function?

16 Practice Review 3 Now, I don't want to ask the user. Instead, I want the main method to tell the dancer to spin 6/3 the first time and 2/1 the last time. What do I use to help me do this now?

17 Practice Review 3 solution
How did parameters and variables help you in your homework? Did it make it easier to keep trying different movements until you found one that looked good? Now pass the dancer something to say. Can't do that with a number.

18 Functions we have used World User question for number World to String
Bunny Distance to

19 Make your own function to have the ballerina ask the user their first name and last name and return the full name. remember a+b world function Story is now: Dancer asks your first and last name Dancer spin right 2 times Dancer spin left 1 time Dancer says hello to you Dancer move forward 1 meter Dancer says goodbye to you

20 New function solution

21 New function questions
Which command used the function? Why did you need a variable in this case to put the function into? Can you use this function without putting it into a variable?

22 Homework Have finished reading chapter 1, 2 & 3
Each person should add 2 methods to any one character. 1) a whoAmI function that will ask the user for his first name and last name and return the full name. 2) a sayHello method that accepts a name parameter and will say "My name is " and the name parameter and "It have a movie for you." When the methods have been added, please upload your character to the discussion board. Then, one person can create a movie with these characters. Create a variable for each character's name. Then it should ask the user to name the characters (meaning set variable to the whoAmI function). Then, it should call the sayHello method on each character, passing in their name. Only one person needs to upload. Please name the world file with both people's names. ex: kris_pepper_and_mary_smith.a2w


Download ppt "Alice Variables Pepper."

Similar presentations


Ads by Google