Week 1 App 1 Moretto

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 7

Appendix A and Chapter 1 Exercises

Appendix A: Installing Greenfoot

A.1 If you do not have it installed already, download and install the latest version of the Java
Development Kit (JDK) from the website
http://www.oracle.com/technetwork/java/javase/downloads/index.html. Click on the JDK button,
circled in the illustration below. Note that the most recent version may be different from the one
illustrated in the diagram. Before you install the JDK, you should uninstall all previous versions of
Java. Follow this link for more information:
http://java.com/en/download/faq/remove_olderversions.xml.

To verify that you have installed Java correctly, go to http://java.com/en/download/index.jsp and click
on “Do I have Java?” circled in the picture below. (Note that the version you see on your computer
may not match the version you see in the diagram.)

Take a screenshot of the resulting webpage verifying that you have the correct version of Java
installed and place it below this paragraph, replacing the text “*** A.1 Place Screenshot Here***.
Week 1, Application 1
Installing the software and verifying that you have done so successfully via a screenshot is the only
action required for Exercise A.1.

If you do not know how to take screenshots, consult one of the following links:

 Windows XP: http://www.microsoft.com/windowsxp/using/setup/tips/screenshot.mspx


 Windows 7 and Windows Vista: http://windows.microsoft.com/en-US/windows7/Use-Snipping-
Tool-to-capture-screen-shots
 Mac OS X: http://www.apple.com/findouthow/mac/#capturescreen

A.2 Download the latest version of the Greenfoot integrated development environment (IDE) at
http://www.greenfoot.org/download/ and install it. Detailed installation instructions are located here:
http://www.greenfoot.org/download/install.html. No response is required for this exercise.

A.3 Download the book scenarios—the programs that are referenced in each chapter—by
navigating to http://www.greenfoot.org/book/ and clicking on The Book scenarios, as illustrated
below.

Week 1, Application 1
The scenarios are compressed in a ZIP file, and they must be extracted before you can use them.
Follow the directions in section A.3 of Appendix A to extract the files. No response is required for this
Exercise.

Chapter 1: Getting to Know Greenfoot

1.1 Place a total of four wombats and five leaves in the world. Take a screenshot to document
your work.

1.2 Briefly explain what the move() and turnLeft() methods do when invoked on a wombat.

It makes the wombat move. And when the turnleft() is selected it turns left

Use the methods to make two wombats face each other. Verify your work with a screenshot.

Week 1, Application 1
1.3 Under what circumstances does the canMove() method return the value false?

When the wombat is at the corner of the world.

1.4 Force a wombat to eat two leaves that you’ve placed in the world. Invoke the
getLeavesEaten() method and take a screenshot to verify the total leaves consumed by the
wombat.

1.5 Identify the directions that correspond with the parameters 0, 1, 2, and 3 in the
setDirection(int direction) method. Describe what happens when you invoke the method
with a parameter that’s greater than 3 or a decimal number, such as 2.5.

When using the parameter 0, 1, 2, and 3 the wombat turn left the number of times specified. Greater
than 3 or decimal it shows an error message. As you can see here.

Week 1, Application 1
1.6 The book described the act() method as “Do whatever you want to do now.” Describe all of
the instinctual behaviors that are programmed into a wombat and may occur when the act() method
is invoked. (Invoke the method by right-clicking the wombat.)

With the act() method is used on a single wombat, it moves one step.

1.7 Describe the difference between invoking the method on a wombat and pressing the Act
button in the Greenfoot window. Assume the World contains only one wombat.

When invoking the method, the wombat moves one step. And with the Act button, it moves one step
too.

1.8 Describe the difference between invoking the method on a wombat and pressing the Act
button in the Greenfoot window. Assume the World contains multiple wombats.

When invoking the method, the wombat moves one step. And with the Act button, all wombats move
one step too.

1.9 Explain what the Run button in the Greenfoot window does.

And with the Run button, all wombats (multiple) move around the world continuously, until the pause
button is clicked and they stop.

1.10 Once you change the reload time of your ship, right-click on the ship and select Inspect. Take
a screenshot to verify the new reload time of 5. (Mac users with a one-button mouse use Control-click
in lieu of right-click.)

Week 1, Application 1
1.11 Play the game for a minute or so and calculate the total number of shots your surviving ship
fired. Explain how you were able to obtain the information.

To obtain the
number of shots, right-clicked and select int getShotsFired()

1.12 Identify the starting speed of the ship when it is placed into the World and the scenario is run.
Explain how you were able to obtain the information.

to obtain the starting speed, right-clicked and selected int


getSpeed()

1.13 As you shoot the asteroids, they break into increasingly smaller pieces. Determine how many
different sized asteroids the game produces and identify the initial stability value of each. By how

Week 1, Application 1
much does that value decrease each time a bullet hits? Is the decrease in stability the same for all
asteroid sizes?

Yes, the decrease is the


same for all asteroid sizes.

1.14 Place a very large asteroid in the World and take a screenshot to verify your work.

I did a very large asteroid (1022) and it move in the screen but there was no fun in that. So I resized it
with a 256 size and it looked large enough for the ship and the scenario.

Week 1, Application 1

You might also like