1 / 14

As you come in…

As you come in…. DOWNLOADS FOR TODAY : http://ce21sandiego.org/2013 Alice Project: Wanda Dann and Don Slater, CMU What do you still need (Alice content/understanding)? (I’ll answer next week…) Index cards As many as you want

matia
Download Presentation

As you come in…

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. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. As you come in… • DOWNLOADS FOR TODAY: • http://ce21sandiego.org/2013 • Alice Project: Wanda Dannand Don Slater, CMU • What do you still need (Alice content/understanding)? (I’ll answer next week…) • Index cards • As many as you want • Counted loops, nested loops, while loops, if statements, nested if statements, functions, expressions, compound boolean expressions, methods parameters

  2. RSVP: Snacks next week • Wrap up at 5:30 • “Snacks and beverages” on the patio 5:30-6:30

  3. Other administrative stuff?

  4. Today’s plan • Methods and Parameters • (Probably next time) Lists

  5. Last Time… • Module 2: Make Methods • Escape • FreakOut • Apologize • Did we – add a parameter to our methods? • How many times should promGuy spin in his freakout? • What should georgeBeetle say as an apology? • What should promGuy say in his freakout?

  6. One should use methods in programs primarily… • For the computer • For the person writing the program • For people reading a program • More than one of the above And WHY is it important?

  7. How to “make” methods • Think of ways in which your planned animation has natural “parts” • Give each of the parts a name • Put the code that makes that “part” happen in a method with that name • Call that method from my first method, in the right order.

  8. Example: Going to a movie… • Walk up to ticket window • Walking in group • Buy tickets • Interact with ticket seller (talking, hand over money, get tickets) • Enter theater • Walk through doors, hand tickets to worker, walk into lobby • Buy snacks… • Take seats… • Make snarky critiques… • …

  9. Exercise! Choices… • Choice 1: Set up the world yourself, or start with one we set up • Do you want practice in setting up world? • Focus on methods/parameters • Which exercise: • Helicopter Flight • Beetle Band

  10. Helicopter Flight [1] • Create a world with a helicopter (Vehicles gallery), airport (Buildings), and a control tower (Buildings). • Part A: • Create a circleTower method that makes the helicopter fly toward the control tower and then around it. In my first method call the circleTower method twice, and then make the helicopter land on the landing strip. • Part B: • Modify circleTower to take a parameter indicating how many times it should “go around” the tower. Change the method call in myFirstMethod to only call the method once, but use a parameter to make it circle 2 time (then try 4 times). • Add another object to the world (maybe a bird or flying dinosaur). Modify the circleTower method to take a second parameter which controls which object should circle the tower. [1] From Learning to Program with Alice textbook, do not use with students

  11. Beetle Band [1] • Create a world with a stage, and 4 beetles (Animals, Bugs) ringoBeetle, paulBeetle, Lennonbeetle, and georgeBeetle on it. Give them each an instrument (you can pick). Set the instrument’s “vehicle” to their beetle (whoever has that instrument). • Create a method called paulSolo that makes paulBeetle do a “solo” but moving up and down while he spins around 1 revolution. Call this method from myFirstMethod. • Modify the method to be called solo – and control which beetle dances by passing it as a parameter. In myFirstMethod, call solo so that each beetle does his solo in order from left to right. • Modify the solo method to be more flexible by sending a parameter which is the number of spins a beetle should do when soloing [1] From Learning to Program with Alice textbook, do not use with students

  12. Below: what happens after the last instruction in the mystery method is finished executing? • The program starts the World.my first method • The program goes back to my first method and calls method XXXXX • The program goes back to my first method and calls method YYYYY • We can’t tell, we need to know more about the storyboard to be able to say

  13. If we write a method called drive, which would not make sense as a parameter to control how drive occurs? • Destination • How fast • Which car • Car color

  14. Which of the following is the best explanation of what makes a good parameter • It’s something that supports common variation in how the method is done • It’s got a meaningful name • It can be either an Object or a number • It’s helps manage complexity in large programs

More Related