![]() ![]() ![]() How similar are the two while loops you wrote? What makes them different? Answer: number of times the code in the for-loop is executed repeatedly (8, first for-loop, and 10, second for-loop). Is there another opportunity to replace repetitive code with a while lago Comment it out and write a while loop instead. ![]() Test your code that uses a while loop with 4 statements instead of 4 statements repeated 8 times 6. Increment your counter variable with the statement 5. Inside ( ) write the three calls that repeat so much: setImage("cat-play-3-piano.png") wait(6): setImage("cat-play-48-piano.png") wait(6) vi. Open bracket (start new line, and close) on another new line. Open (and close ) and inside the parentheses write ne 8 iv. Initialize your counter variable with the statement: n=1 ii. ![]() Start a while loop on the line ABOVE the second call to play Sound: Greenfoot playSound("Snoopy.wav), which is online 104. Select these lines of code and use F8 key (or select Edit-Comment). Comment out the first block of code that uses these three lines repeatedly clines 71 to 102). We can make the cat do the same thing with a while loop in which we use each of the calls identified at #3 only once a. wait(6), and setImage("cat-play-4B-piano.png"). Which are the lines of code that repeat the most? Answer: setImage["cat-play-3-piano.png"). When you have code that repeatedly does the same thing, you can use a while loop to shorten the text of code. We are going to alter the code to use while loops. Describe what is happening in the body of the play method. On the cat object placed in the CatWorld, call the playPiano method. Which of the following is not a component of a while loop? Mark for Review (1) Points while keyword if statement (*) Control operator Loop variable Local variable Incorrect. In Greenfoot, what types of values cannot be stored in a local variable? Mark for Review (1) Points Method (*) Class name World name Objects Integers Correct 5. Image files from 1-119 are associated with image1. (*) The variable, image1, cannot use the image file, duke12.png. The image file, duke12.png, is assigned to the variable image1. What does the following programming statement mean?image1 = new GreenfootImage(“duke12.png”) Mark for Review (1) Points The image file, duke12.png, has just been drawn and imported into the scenario. Defines the access specifier used with the variable. Defines the instance that the variable is associated with. (*) Defines which class the variable is associated with. In Greenfoot, what is the purpose of the variable type? Mark for Review (1) Points Defines what kind of data to store in the variable. In Greenfoot, which method body correctly adds an instance of the World to a scenario, with size x = 300 y = 300 and a resolution of 2 pixels per cell? Mark for Review (1) Points super(300,300,2) (*) Super(300,300,2) world(300, 300, 2) super(2,300,300) Correct 2. In Greenfoot, after a subclass is created, what has to occur before instances can be added to the scenario? Mark for Review (1) Points Creation of an instance Editing of source code Compilation (*) Creation of source code Incorrect. True or false? Mark for Review (1) Points True (*) False Correct 15. From your Greenfoot lessons, the reset button resets the scenario back to its initial position. True or false? Mark for Review (1) Points True False (*) Incorrect. In Greenfoot, after a subclass is created and compiled, you cannot edit the subclass’s source code. A subclass has what kind of relationship to a superclass? Mark for Review (1) Points “a-is” “is-by” “is-a” (*) “for-what” Incorrect. True or false? Mark for Review (1) Points True (*) False Correct 12. When designing a game in Greenfoot, it helps to define the actions that will take place in a textual storyboard. In Greenfoot, which of the following options are not possible when associating an image file with an instance? Mark for Review (1) Points Add a video (*) Import an image Draw an image Select an image from the Greenfoot library Correct 11. In Greenfoot, the move method expects what type of information in its parameters? Mark for Review (1) Points Integer of steps to move forward (*) Degrees to turn True or false response String statement Correct 10. In Greenfoot, the body of the method is located in between which of the following characters? Mark for Review(1) Points Square brackets Curly brackets (*) Asterisks ** Incorrect. In Greenfoot, the move method expects what type of information in its parameters? Mark for Review(1) Points Degrees to turn True or false response Integer of steps to move forward (*) String statement3. Which of the following is an incorrectly written programming statement? Mark for Review(1) Points move(2) move(): (*) turn(25) turn(2) 2. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |