Presentation on theme: "PIIT Computer Science Summer Camp - Alice July 10, 2012 Brenda Parker Computer Science Department MTSU."— Presentation transcript:
PIIT Computer Science Summer Camp - Alice July 10, 2012 Brenda Parker Computer Science Department MTSU
April 21, 2015Brenda Parker - Alice Workshop2 Welcome – Day 2 Demonstrate Alice Worlds Review Contest
April 21, 2015Brenda Parker - Alice Workshop3 Workshop Agenda Discuss how programmers develop programs (software) Apply the “software life” cycle to Alice Create “custom” methods for Alice Objects
April 21, 2015Brenda Parker - Alice Workshop4 Part I – Developing Software Programmers use the “Software Development Cycle” 1.Design Phase 2.Implementation Phase 3.Testing Phase 4.Debugging Phase
April 21, 2015Brenda Parker - Alice Workshop5 Developing Software Design Phase Programmers will learn about all specifications (what the program should do) Programmers will create a list of instructions needed to solve the problem Programmers will break complex methods down into a smaller methods called “modules”
April 21, 2015Brenda Parker - Alice Workshop6 Developing Software Design Phase In Alice, we should learn : 1.Which objects are needed? 2.Which methods are needed? 3.What does the first scene look like?
April 21, 2015Brenda Parker - Alice Workshop7 Developing Software Implementation Phase Programmers will use a programming language to enter instructions (coding) In Alice, we add and position objects and code methods for the objects
April 21, 2015Brenda Parker - Alice Workshop8 Developing Software Testing Phase Programmers will “test” the program to see if it works properly and meets its specifications. Testing involves testing each method to see if it works by itself and with other methods
Developing Software Debugging Phase Programmers will correct mistakes found in the Testing Phase In Alice, correct the design of each method and correct the initial state of the world April 21, 20159Brenda Parker - Alice Workshop
Good Programmers know the importance of DESIGN 1. Design their software carefully! 2.Use a “Modular” design break a large task down into smaller tasks called modules Each module performs one task In Alice, this is performed by creating “user defined methods” = “Custom World Methods”
Creating User Methods Why? 1.Makes Alice programs easier to debug 2.Makes Alice programs easier to create 3.Supports “modular” design Now, let’s learn to create our own methods! April 21, Brenda Parker - Alice Workshop
April 21, 2015Brenda Parker - Alice Workshop12 World Custom Methods Created by the user Used to break up large complex methods into smaller more manageable methods
Example Suppose we wish to create an “Ice Skater World” which opens with an introduction by the skater. Then, the skater skates around 2 cones and jumps in the air. At the end the skater says goodbye and the camera circles the skater.
Example We would break this task down into 3 separate tasks! 1.Opening Scene 2.Skating Scene 3.Closing Scene Therefore, we need to create these three methods!
Design Phase 3.Describr beginning scene 1.Snow world 2.Class lake environment 3.Add and position objects 1.Red and green cones 2.Skater in the middle of the cones
Implementation Phase Open Alice Choose snow world add Class Lake Environment Add ice skater and two cones (red and green) as shown Save your world as iceSkate1.a2w
Implementation Phase (coding) Write code for your three methods –openingScene –skatingScene –closingScene
April 21, 2015Brenda Parker - Alice Workshop19 Custom World Method How to create and use Custom World Methods 1.Name the method 2.Write the method 3.Call the method (Tell Alice to execute the method)
April 21, 2015Brenda Parker - Alice Workshop20 Create your Methods 1.Name your method 1.Click on World in the Object Tree 2.Click on create new method in the World’s Details Panel 3.Name the method – openingScene Repeat above for the skatingScene and the closingScene methods
April 21, 2015Brenda Parker - Alice Workshop21 Custom World Method 2. Write the method Click on the world object in the object tree Click on methods Click edit to write the method
Testing Phase 1.Test each method to see if each method works as desired 2.Test to see if the methods work with other methods.
Testing Phase –Part 1 Test each method to see if it works. 1.Test the openingScene method 2.Play the video to see if it works. 3.If it doesn’t work properly, edit the method and replay.
Testing Phase – Part 1 Test all methods to see if they work properly.
Testing Phase – Part 2 Test methods to see if they work with other methods. 1.Open world.my first method 2.Click and drag your method names to the editor window as shown. 3.Make sure that world.my first method begins when the world starts.
April 21, 2015Brenda Parker - Alice Workshop26 Testing Phase - Part 2
Debugging Phase Developers should attempt to correct mistakes that have been found. During the debugging phase, developers may often find improvements that can be made.
Practice VII Questions 1.What is the difference between “primitive” methods and custom methods? 2. Give two reasons that custom methods are often used in Alice. 3. What is the name of the method that is executed when your animation first begins? 4. What are the three steps for creating custom world methods? 5.What does “call” the method mean? 6. How are custom methods “called”? 7. Name the 4 steps of the Software Development Cycle. April 21, Brenda Parker - Alice Workshop
April 21, 2015Brenda Parker - Alice Workshop29 Software Documentation Written text and visual material (chart) that describe computer software Good software requires good documentation. –Comments that appear in the program –Notes that appear while the program is running –Instruction manual supplied with the software
April 21, 2015Brenda Parker - Alice Workshop30 Alice Documentation Add “Comment Tiles” which Name the program (peguinsDance.a2w) Programmer’s Name Date Program details
April 21, 2015Brenda Parker - Alice Workshop31 Adding Comments 1.Drag a copy of the comment tile from the bottom of the Editor Area and drop it into the method.
April 21, 2015Brenda Parker - Alice Workshop32 Adding Comments 2. Click the phrase No comment and type in your information.
ACTIVITY Use the “software development cycle” and develop your own video. To receive points for this exercise, you should design your animation using the DAY 2 Assignment Sheet. Some ideas: 1)Create a story about dancing penguins 2)Create a story about space invaders 3)Create a story about trip to the moon
April 21, 2015Brenda Parker - Alice Workshop34 Practice VIII Choose 1 of the following. Be sure to add comments: 1.Page AL #1 Penguin Dance 2.Page AL #2 Airport Animation 3.Page AL #3 Ballerina Movements 4.Create your own story (must have a beginning, a middle and an end). Use primitive methods as well as your own methods.
Using Logic and Looping Structures Logic If –then– else If something is true do this else do this! April 21, Brenda Parker - Alice Workshop
LOGIC Example: Suppose we have two objects, Elvis and a cuckoo clock. Let’s ask the user if the user wants the Elvis to sing or does the user wish to see the cuckoo clock sound out 3 times! April 21, Brenda Parker - Alice Workshop
How do we allow the user to input a value? Asking the user for input while a program is running is called “interactive input”. How do we do this in Alice? April 21, Brenda Parker - Alice Workshop
User Input Example Suppose that we have a world with Elvis and a cuckoo clock. The program should ask, “Do you want Elvis to sing? If the user answers, “YES”, Elvis will sing. Otherwise, the cuckoo bird will sound out cuckoo 3 times. April 21, Brenda Parker - Alice Workshop
User Input Example 1 Create a world with the two objects. 2. Drag the If/Else Control Structure to the Editor Area. 3.Set the If condition to true 4.Select the world function called “ask user for yes or no” 5.Use the function in the “if else” structure. 6. Click Question=Yes or No? to add the question. April 21, Brenda Parker - Alice Workshop
User Input Example April 21, Brenda Parker - Alice Workshop
Better Example – User Defined Methods
Using Logic and Looping Structures Loop – statements that are executed repeatedly. Types of Loops While Loop For all in order For all together April 21, Brenda Parker - Alice Workshop
April 21, 2015Brenda Parker - Alice Workshop43 Looping Structures While Continue to repeat until a certain condition occurs. Example: Suppose that we have a penguin that we wish to continue to move toward a hole in the ice until he “almost” reaches the hole!
Looping Structures Loop Used to specify that a group of statements is to be repeated a set number of times April 21, Brenda Parker - Alice Workshop
Example Edit the elvisSing method so that the user is asked to input the number of times Elvis should sing. 1.Drag the loop structure to the beginning of the method and set to 1 time. 2.Drag the world function “ask the user for a number” and place in the 1 time slot 3.Choose other to ask appropriate question. 4.Drag methods to the loop structure
variables Variable – a name that refers to a piece of the program’s memory, in which a value can be stored, retrieved, and changed. In Alice, there are two kinds of variables –World variable – variables that can be used by all methods –Method variable – variable that can only be used in a method that creates it.
Method Variable 1.Click on “create new variable” 2.Indicate type of variable 1.Number 2.Boolean 3.Object 4.Other 3.Give the variable a name 4.Click on OK
Example Use the Elvis and cuckoo clock world and update the program so that you ask the user how many times the Elvis/cuckoo should sing. Use a variable called numberOfTimes (camelCase)
Using Variable in a Loop 1.Edit the method to contain the variable 2.Click create new variable called numberOfTimes 3.Drag variable to beginning of method and set value to expressions – numberOfTimes 4.Drag World function “ask user for a number” and place in set value to and add “How many times should the cuckoo sing?” 5.Drag loop and set expression to numberOfTimes 6.Drag needed methods into the loop structure
Practice IX Create an Alice project called yourLastNameDay2.a2w which meets the following requirements. 1.Uses at least 3 user-defined methods 2.Uses at least 1 variable 3.Requires user input 4.Tells an “interesting” story 5.Uses if/else structure 6.Contains a loop or while structure 7.Contains proper documentation 8.Print your program 9.Submit your program to the Day 2 folder April 21, Brenda Parker - Alice Workshop