chapter 1 - getting to know greenfoot
DESCRIPTION
Chapter 1 - Getting to know Greenfoot. Bruce Chittenden. Desktop Icon. 1.1 Getting Started. World. Class Diagram. Execution Controls. 1.2 Objects and Classes. Right Click on Wombat. Drag to World. Click New Wombat(). Exercise 1.1. 1.3 Interacting with Objects. - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Chapter 1 - Getting to know Greenfoot](https://reader035.vdocuments.us/reader035/viewer/2022062310/56816301550346895dd3789a/html5/thumbnails/1.jpg)
Chapter 1 - Getting to know Greenfoot
Bruce Chittenden
![Page 2: Chapter 1 - Getting to know Greenfoot](https://reader035.vdocuments.us/reader035/viewer/2022062310/56816301550346895dd3789a/html5/thumbnails/2.jpg)
Desktop Icon
![Page 3: Chapter 1 - Getting to know Greenfoot](https://reader035.vdocuments.us/reader035/viewer/2022062310/56816301550346895dd3789a/html5/thumbnails/3.jpg)
1.1 Getting Started
World
ClassDiagram
ExecutionControls
![Page 4: Chapter 1 - Getting to know Greenfoot](https://reader035.vdocuments.us/reader035/viewer/2022062310/56816301550346895dd3789a/html5/thumbnails/4.jpg)
1.2 Objects and ClassesRight Click on Wombat
Click New Wombat()
Drag to World
![Page 5: Chapter 1 - Getting to know Greenfoot](https://reader035.vdocuments.us/reader035/viewer/2022062310/56816301550346895dd3789a/html5/thumbnails/5.jpg)
Exercise 1.1
![Page 6: Chapter 1 - Getting to know Greenfoot](https://reader035.vdocuments.us/reader035/viewer/2022062310/56816301550346895dd3789a/html5/thumbnails/6.jpg)
1.3 Interacting with Objects
Invoke the Move method
Right Click on the Wombat
![Page 7: Chapter 1 - Getting to know Greenfoot](https://reader035.vdocuments.us/reader035/viewer/2022062310/56816301550346895dd3789a/html5/thumbnails/7.jpg)
1.4 Return Types
![Page 8: Chapter 1 - Getting to know Greenfoot](https://reader035.vdocuments.us/reader035/viewer/2022062310/56816301550346895dd3789a/html5/thumbnails/8.jpg)
Exercise 1.3
![Page 9: Chapter 1 - Getting to know Greenfoot](https://reader035.vdocuments.us/reader035/viewer/2022062310/56816301550346895dd3789a/html5/thumbnails/9.jpg)
Exercise 1.3
![Page 10: Chapter 1 - Getting to know Greenfoot](https://reader035.vdocuments.us/reader035/viewer/2022062310/56816301550346895dd3789a/html5/thumbnails/10.jpg)
Exercise 1.4
![Page 11: Chapter 1 - Getting to know Greenfoot](https://reader035.vdocuments.us/reader035/viewer/2022062310/56816301550346895dd3789a/html5/thumbnails/11.jpg)
1.5 Parameters
![Page 12: Chapter 1 - Getting to know Greenfoot](https://reader035.vdocuments.us/reader035/viewer/2022062310/56816301550346895dd3789a/html5/thumbnails/12.jpg)
Exercise 1.5
![Page 13: Chapter 1 - Getting to know Greenfoot](https://reader035.vdocuments.us/reader035/viewer/2022062310/56816301550346895dd3789a/html5/thumbnails/13.jpg)
Exercise 1.5
![Page 14: Chapter 1 - Getting to know Greenfoot](https://reader035.vdocuments.us/reader035/viewer/2022062310/56816301550346895dd3789a/html5/thumbnails/14.jpg)
Exercise 1.5
1
3
2
0
![Page 15: Chapter 1 - Getting to know Greenfoot](https://reader035.vdocuments.us/reader035/viewer/2022062310/56816301550346895dd3789a/html5/thumbnails/15.jpg)
Exercise 1.5
Parameter > 3 Does Nothing
![Page 16: Chapter 1 - Getting to know Greenfoot](https://reader035.vdocuments.us/reader035/viewer/2022062310/56816301550346895dd3789a/html5/thumbnails/16.jpg)
Exercise 1.5
Non-Integer Returns Error
![Page 17: Chapter 1 - Getting to know Greenfoot](https://reader035.vdocuments.us/reader035/viewer/2022062310/56816301550346895dd3789a/html5/thumbnails/17.jpg)
1.6 Greenfoot Execution
![Page 18: Chapter 1 - Getting to know Greenfoot](https://reader035.vdocuments.us/reader035/viewer/2022062310/56816301550346895dd3789a/html5/thumbnails/18.jpg)
Exercise 1.6
![Page 19: Chapter 1 - Getting to know Greenfoot](https://reader035.vdocuments.us/reader035/viewer/2022062310/56816301550346895dd3789a/html5/thumbnails/19.jpg)
Exercise 1.6
Wombat Moves toward the Leaves
![Page 20: Chapter 1 - Getting to know Greenfoot](https://reader035.vdocuments.us/reader035/viewer/2022062310/56816301550346895dd3789a/html5/thumbnails/20.jpg)
Exercise 1.6
Wombat Moves to Leaves
![Page 21: Chapter 1 - Getting to know Greenfoot](https://reader035.vdocuments.us/reader035/viewer/2022062310/56816301550346895dd3789a/html5/thumbnails/21.jpg)
Example 1.7
Wombat Eats Leaf
![Page 22: Chapter 1 - Getting to know Greenfoot](https://reader035.vdocuments.us/reader035/viewer/2022062310/56816301550346895dd3789a/html5/thumbnails/22.jpg)
Exercise 1.8
![Page 23: Chapter 1 - Getting to know Greenfoot](https://reader035.vdocuments.us/reader035/viewer/2022062310/56816301550346895dd3789a/html5/thumbnails/23.jpg)
Exercise 1.8
The >Act Execution Control Affects All the Wombats
![Page 24: Chapter 1 - Getting to know Greenfoot](https://reader035.vdocuments.us/reader035/viewer/2022062310/56816301550346895dd3789a/html5/thumbnails/24.jpg)
Exercise 1.9
Wombat Runs Around the Edge of the World
![Page 25: Chapter 1 - Getting to know Greenfoot](https://reader035.vdocuments.us/reader035/viewer/2022062310/56816301550346895dd3789a/html5/thumbnails/25.jpg)
Exercise 1.9
• Act Method– If we’re sitting on a leaf, eat the leaf– Otherwise, if we can move forward, move forward– Otherwise, turn left
![Page 26: Chapter 1 - Getting to know Greenfoot](https://reader035.vdocuments.us/reader035/viewer/2022062310/56816301550346895dd3789a/html5/thumbnails/26.jpg)
1.7 A Second Example
![Page 27: Chapter 1 - Getting to know Greenfoot](https://reader035.vdocuments.us/reader035/viewer/2022062310/56816301550346895dd3789a/html5/thumbnails/27.jpg)
1.8 Understanding the Class Diagram
World Class is always there in Greenfoot scenarios, it is built-in. Space represents a specific world for this scenario
Arrows show relationships
Explosion and Mover are subclasses of Actor
Bullet, Rocket, and Asteroid are subclasses of Mover.
Vector is a helper class
![Page 28: Chapter 1 - Getting to know Greenfoot](https://reader035.vdocuments.us/reader035/viewer/2022062310/56816301550346895dd3789a/html5/thumbnails/28.jpg)
1.9 Playing with AsteroidsStart Playing by Creating Some Actor Objects (Objects of the Subclass of Actor). Create Objects for Rocket, Bullet, Asteroid, and Explosion
![Page 29: Chapter 1 - Getting to know Greenfoot](https://reader035.vdocuments.us/reader035/viewer/2022062310/56816301550346895dd3789a/html5/thumbnails/29.jpg)
Exercise 1.10
Right Click on the Object
![Page 30: Chapter 1 - Getting to know Greenfoot](https://reader035.vdocuments.us/reader035/viewer/2022062310/56816301550346895dd3789a/html5/thumbnails/30.jpg)
Exercise 1.10
Click on setGunReloadTime and Type 5
![Page 31: Chapter 1 - Getting to know Greenfoot](https://reader035.vdocuments.us/reader035/viewer/2022062310/56816301550346895dd3789a/html5/thumbnails/31.jpg)
Exercise 1.11
Right Click on the Object and Select Inspect
![Page 32: Chapter 1 - Getting to know Greenfoot](https://reader035.vdocuments.us/reader035/viewer/2022062310/56816301550346895dd3789a/html5/thumbnails/32.jpg)
Exercise 1.11
Right Click on the Object and Select Inspect
![Page 33: Chapter 1 - Getting to know Greenfoot](https://reader035.vdocuments.us/reader035/viewer/2022062310/56816301550346895dd3789a/html5/thumbnails/33.jpg)
Exercise 1.12
Right Click on the Object and Select getSpeed ( )
![Page 34: Chapter 1 - Getting to know Greenfoot](https://reader035.vdocuments.us/reader035/viewer/2022062310/56816301550346895dd3789a/html5/thumbnails/34.jpg)
Exercise 1.12
![Page 35: Chapter 1 - Getting to know Greenfoot](https://reader035.vdocuments.us/reader035/viewer/2022062310/56816301550346895dd3789a/html5/thumbnails/35.jpg)
Exercise 1.13
![Page 36: Chapter 1 - Getting to know Greenfoot](https://reader035.vdocuments.us/reader035/viewer/2022062310/56816301550346895dd3789a/html5/thumbnails/36.jpg)
Exercise 1.14
Right Click on the Object and Select setSize(int Size) and Set the Size to 256
![Page 37: Chapter 1 - Getting to know Greenfoot](https://reader035.vdocuments.us/reader035/viewer/2022062310/56816301550346895dd3789a/html5/thumbnails/37.jpg)
1.10 Source Code
Right Click on the Class and Select Open editor
![Page 38: Chapter 1 - Getting to know Greenfoot](https://reader035.vdocuments.us/reader035/viewer/2022062310/56816301550346895dd3789a/html5/thumbnails/38.jpg)
Source Code for Rocket
![Page 39: Chapter 1 - Getting to know Greenfoot](https://reader035.vdocuments.us/reader035/viewer/2022062310/56816301550346895dd3789a/html5/thumbnails/39.jpg)
Exercise 1.15
Change gunReloadTime from 20 to 5
![Page 40: Chapter 1 - Getting to know Greenfoot](https://reader035.vdocuments.us/reader035/viewer/2022062310/56816301550346895dd3789a/html5/thumbnails/40.jpg)
Exercise 1.15
![Page 41: Chapter 1 - Getting to know Greenfoot](https://reader035.vdocuments.us/reader035/viewer/2022062310/56816301550346895dd3789a/html5/thumbnails/41.jpg)
Exercise 1.15
Class Changed Class Compiled
![Page 42: Chapter 1 - Getting to know Greenfoot](https://reader035.vdocuments.us/reader035/viewer/2022062310/56816301550346895dd3789a/html5/thumbnails/42.jpg)
1.11 SummaryIn this chapter, we have seen what Greenfoot scenarios can look like and how to interact with them. We have seen how to create objects and how to communicate with these objects by invoking their methods. Some methods are commands to objects, while other methods return information about the object. Parameters are used to provide additional information to methods, while return values pass information back to the caller.
![Page 43: Chapter 1 - Getting to know Greenfoot](https://reader035.vdocuments.us/reader035/viewer/2022062310/56816301550346895dd3789a/html5/thumbnails/43.jpg)
Concept Summary