4/5/2023 0 Comments Greenfoot arrays![]() ![]() In Greenfoot, when is a local variable most often used? When the end to the act method isn't established. When the end to the code isn't established. From your Greenfoot lessons, when do infinite loops occur? In Greenfoot modifying an actors constructor to accept an initial speed is a form of abstraction? (*) Adding a property to a Class Incorrect. 11.From your Greenfoot lessons, which one of the following is an example of when an abstraction technique is used?Īdding a property to an instance Initialising a variable Passing a paramater in a constructor to set an initial speed. In Greenfoot, you can cast an Actor class to a World class? In Greenfoot, which method is used to end a game?ĭuke.stop( ) Game.stop(1) Greenfoot.stop( ) (*) Class.stop( ) Correctġ0. The GreenfootImage class enables Greenfoot actors to maintain their visible image by holding an object of type GreenfootImage. In Greenfoot, the = operator is used to test if two values are equal. True (*) False Correct 5.In Greenfoot when you use the method to retrieve input from the user, the scenario will continue to run in the background?įalse (*) Correct 6.In Greenfoot, you can only interact with the scenario using a keyboard. True (*) False Correct 4.In Greenfoot, the sound file must be saved in the scenario and written in the source code for it to play. 3.In Greenfoot, a way to have all subclasses of a superclass inherit a method is by adding the method to the superclass. HasCollided() hasTouched() isCollision() isInContactWith() isTouching() (*) Incorrect. True (*) False Correct 2.Which actor method is used to detect a simple collision? This web page was created to supplement a course offered by TheĬommons Attribution 3.0 Unported License.Section 3 - Quiz 2 L6-L10 (Answer all questions in this section) 1.In Greenfoot a collision is when 2 actors touch? For more on CodingBat, see the Introduction to CodingBat video on the Writing Methods page. Retake as needed to get a perfect score.ĬodingBat is a special environment for writing and testing methods with non-void return types. When you understand how return values are used, take this quiz. The method header for setLocation is void setLocation(int,int), which means it needs two ints for input. Notice also that we used getX twice for our call to setLocation. Notice that turn, move, setRotation, and setLocation all have void return types and accept int parameters. Since getX returns an int, you can use that int any way you like. The turtle has retrieved the correct information (its X coordinate), but it doesn't know what to do with that information. Notice that nothing happens when you press the Act button. This information may be useful, but just calling this method doesn't tell the object how to use the information. For example, if the X coordinate of the object is 327, the method will return an integer of 327. The int before the method name tells us that the method returns an integer. They ask an object for information, but they don't tell the object what to do with that information.įor example, the method header for the getX method is: Methods with other return types (like int or boolean) are like questions. You'll see that the turtle turns 5 degrees every time you press the Act button. The act method below calls the turn method. Methods with void return types are like commands. The void keyword before the name of the method tells us the return type. For example, the method header for the turn method is: This video explains how to use methods with return types. GreenfootBook Page (includes links to book scenarios).Greenfoot Documentation (includes tutorials and videos).Java Tutorial Trail: Learning the Java Language Using Methods with Non-Void Return Types.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |