Final Review Quest

<< Back

Instructions

We complete a series of exercises to prepare for the final exam. For the timed portions, each guild whose members all complete that portion within the specified time receives the amount of XP assigned for the problem (10 XP total). Guild members are encouraged to assist other guild members to complete the quest in a timely manner.

After the time has expired, the instructor will view the projects to ensure each guild member has completed the project. Make sure your individual work is present on your screen and easily accessible by the instructor. Any incomplete exercises, incorrectly coded exercises, working outside the allotted time, or delays during assessment will result in no award of the XP for the entire guild.

After each member of your guild has working code, you may work ahead. We will stop the review after about one hour even if we do not complete all the sections. Save your final work as this quest is submitted as part of the final lab.

Review Topics


A. Start a Scenario

  1. Review lessons:
  2. Complete the following steps to create a new scenario: (5m: 1 XP)
    1. Download and save the following file to a convenient location like the Desktop. Unzip the file and double-click project.greenfoot to start the scenario.
      Scenario file: finalprac.zip.
    2. After downloading, add your name to the README.TXT accessed by following the Scenario menu to the Scenario Information item.
    3. Add a World subclass named FruitWorld with a background image of "fruit.jpg". Make the world size 600 pixels wide by 400 pixels high and a cell size of one. Compile your code to verify it works.
  3. When complete, have your scenario screen visible with the "fruit.jpg" background showing.
  4. Help other guild members to complete their work as needed.

B. Add a Fruit

  1. Review lessons:
  2. Complete the following steps to add random flying fruits to the scenario: (8m: 2 XP)
    1. Create a class named Fruit, using the "apple.png" image.
    2. Add code for the Fruit to move in the world, turning at the walls.
    3. In the FruitWorld constructor, use a for-loop and random numbers to add three fruits to the world at random locations.
  3. When complete, have your scenario screen visible with the three fruits moving around the screen and the FruitWorld editor open to one side so it does not obscure the scenario screen.
  4. Help other guild members to complete their work as needed.

C. Create an Explosion

  1. Review lessons:
  2. Complete the following steps to add an explosion to the scenario: (20m: 5 XP)
    1. Create an Actor subclass named Boom using the explosion image.
    2. Declare a private static final int variable named NUMBER_IMAGES and assign it a value of 12.
    3. Add a private static array for holding GreenfootImage objects. (10.2.2)
    4. In the Boom class, write a method with the following header:
      public static void initializeImages()
      Use the example in lesson 10.2.2 as a starter and change the image to "explosion.png".

      We want the method to initialize the array of images the first time, and only the first time, when the method is called with a set of 12 images derived from "explosion.png". The explosion starts with a size of 50 and grows by 20 each scenario cycle. To do this we repurpose the use of the size variable like:

      int size = 50;
      for (...)
      {
          // assign images and scale them
          size = size + 20;
      }
      
    5. Write a default constructor for the Boom class that calls the initializeImages() method and plays the sound "explosion.wav".
    6. In the Boom class, add code to control which image of the explosion is displayed over multiple scenario cycles. After the last explosion image is displayed, remove the explosion object from the world. Use the grow() method of 10.2.3 and call the grow() method from the act() method of Boom.
    7. Also in the act() method, use removeTouching() to remove any fruit from the world that the explosion touches.

      Since grow() can remove the explosion from the world, call removeTouching() before calling the grow() method.

    8. Verify your code by adding an explosion to the world and checking that your explosion removes any Fruit objects it touches.
  3. When complete, have your scenario screen visible with the three fruits moving randomly around the screen and the Boom editor open to one side so it does not obscure the scenario screen.

    Be prepared when the instructor asks you to place a Boom object in the world to demonstrate your work so the verification proceeds quickly.

  4. Help other guild members to complete their work as needed.

D. Code a Bomb Class

  1. Review lessons:
  2. Complete the following steps to add a bomb to the scenario: (8m: 2 XP)
    1. Create an Actor subclass named Bomb, choosing a suitable image.
    2. In the act() method of Bomb, add an if-statement to test if the bomb touches a fruit.
    3. If the bomb touches a fruit, then add an explosion and remove this Bomb object from the world.
    4. In the FruitWorld constructor, add four bombs to the world at random locations.
  3. When you complete your scenario, have your scenario screen visible with the three fruits and four bombs visible. Also have the Bomb editor open to one side so it does not obscure the scenario screen.
  4. Help other guild members to complete their work as needed.

<< Back