CSE 113 - Spring 2011 - Banner
  • CSE 113 - Spring 2011
CSE 113 - Spring 2011 - Navigation
CSE 113 - Spring 2011 - Practice Assignment 5

Practice Assignment 5
Last modified: February 20 2011 03:25:20 PM

CSE 113 - Spring 2011 - Announcements

Virus Patrol

If you don't remember how to do any of the steps (like, copying, zipping, etc), please refer back to Lab 1.

First, you will need to copy over the scenario for this assignment. If you are working from home, you can download the scenario here. If you are in lab, the scenario is located in /eng/class/notes/cse113/scenarios/PracticeAssignment5.

Take note of the following classes in the scenario:

  • Body - The world in which this scenario takes place.
  • Virus - A virus (enemy) in the scenario.
  • VirusPatrol - Our hero in this scenario.

 

You are to complete the following functionality for the scenario.

Run Away from Viruses

Fill in the checkForVirus method so that if the VirusPatrol can see a Virus, it turns away from it. You can specify how many degrees to turn (it can be random if you'd like).

Fill in the Constructor for Body

Modify the constructor in the Body class to create 10 viruses and 1 virus patrol and put each of them in the world at random locations.

Counting the viruses

Add an instance variable to the VirusPatrol class to count the number of viruses the virus patrol has run into. Create a constructor for the VirusPatrol class and initialize the instance variable to zero inside the constructor. Modify your code in checkForViruses so that when the virus patrol can see a virus, the count is increased by 1.

Changing Images

You will once again modify thwe checkForViruses code so that after a virus has been hit and the counter updated and the patrol turned, the patrol checks the value of the instance variable. If the value is greater than or equal to 10, then the image of the virus patrol should change to skull.png.


Submitting the Assignment

Once you have finished your changes to the code, you will submit the zipped up version of the practice assignment 5 scenario.

For directions on submitting, please see here.

This practice assignment is due on Friday, March 18th at 11:59:59pm.


Grading Information

Please make sure to look at your grading information on Web-CAT. See the grading information page for more details about how to interpret Web-CAT grade reports. (At this time, the Web-CAT grading is not enabled for this assignment.)

The following tests were run on your assignment submission. Each test was given equal weight, so 20 points each part.

  1. When the Body is created, 10 viruses are placed randomly in the world.
  2. When the Body is created, 1 VirusPatrol is placed randomly in the world.
  3. There is an instance variable in the VirusPatrol class to keep track of the number of viruses that have been encountered.
  4. When the VirusPatrol encounters a Virus, the instance variable is properly updated.
  5. When the VirusPatrol encounters 10 Viruses, the image of the VirusPatrol changes to "skull.png".

Lab authored by Adrienne Decker

CSE 113 - Spring 2011 - Footer

Page maintained by Adrienne Decker

Contact: adrienne@buffalo.edu | 130 Bell Hall | (716)645-3184