CSE 113 - Spring 2010 - Banner
UB -
University at Buffalo, The State University of New York Computer Science and Engineering
  • CSE 113 - Spring 2010
CSE 113 - Spring 2010 - Navigation
CSE 113 - Spring 2010 - Announcements

Lab 2

CSE 113 - Spring 2010 - Announcements

Copy a scenario into your account & Open the Scenario

Go to /eng/class/notes/cse113/scenarios/ and copy the Lab2 directory/scenario to your account and open Greenfoot and the copied scenario

If you are working from home, you can get the Lab 2 scenario from here.


Required Lab Tasks

Please note that your Hero's act method is already populated with some Java code. The first method call is already there, and the empty method definition is already there. For the second method call, the method definition is not the in the file. You will need to put in the method definition. For the remainder of the functionality, you need to add the method definition and the appropriate method calls to the Hero class. You must follow the names of the methods indicated exactly because the lab will be graded somewhat automatically. Failure to have the correct methods defined will cause your grade to be low because the system will not be able to grade your submission properly.

Moving Hero

The hero in this scenario should move "forward" whenever act is called. Note that Hero is a subclass of Actor, so there is no move method defined, you must define the method yourself. There is code already in the scenario to help you with this. You simply need to fill in the move method body.

Hero Checks for Edges and Wrap Around

The hero must check for the edges of the world and wrap around if it reaches an edge left/right and top/bottom. There is a hint for this in the scenario already as well. Create a method named checkForEdges and use it to help you detect the edges of the world and move the hero around.

Hero Turns Right

When the user presses the right arrow key, the hero should turn right. The amount of degrees is up to you. You need to create a method named turnRight() in your Hero class.

Hero Turns Left

When the user presses the left arrow key, the hero should turn left. The amount of degrees is up to you. You need to create a method named turnLeft() in your Hero class.

Create Additional Actors

You should create classes for each of the following objects that will be in the scenario: Mushroom, Flower, GoldBall, TeddyBear, Skull.

Populate the Scenario

Your scenario should open with the following at various locations throughout the world: one hero, six mushrooms, four flowers, one gold ball, one teddy bear.

Hero Finds a Flower

If the hero encounters a flower, the hero picks it up. The hero should keep track of how many flowers the hero has encountered and picked up. There must be a method named checkForFlower in your Hero class.

Hero Finds a Gold Ball

If the hero encounters a gold ball, the hero picks it up. Picking up a gold ball causes another gold ball to appear somewhere else in the world at a random location. There must be a method named checkForGoldBall in your Hero class.

Hero Finds a Mushroom

Mushrooms disappear when the hero encounters them. If the hero encounters one mushroom, nothing happens in the program. If the hero encounters a second mushroom, the hero should turn into an animal (visually - that is, change the image) and the hero loses all the flowers he/she has been carrying around. The flowers go back into the world at random locations. If the hero encounters three mushrooms, Skull objects are added to the world at random locations. You should add three skulls to the world. There must be a method named checkForMushrooms in your Hero class.

Modify Behavior for Gold Ball

Picking up a gold ball also allows the hero's image to return to normal.

Hero Finds a Teddy Bear

When the hero encounters a teddy bear, the hero picks up the bear and all the skulls leave the world. If when picking up the bear, the hero has more than one flower, then another teddy bear will appear in the world. There must be a method named checkForTeddyBear in your Hero class.

Hero Encounters a Skull

If the hero encounters a skull, the scenario stops. There must be a method named checkForSkull in your Hero class.


Working outside of Bell 340

If you would like to continue this work outside of Bell 340, there are a few options available to you. You can work in Bell 101, which is an engineering public computing site. Information about the differences you may encounter when in Bell 101 are located here.

If you want to work on your own machine, totally independent of the lab environment, you will need several things. This page will explain where to look for information about downloading the files and programs you need to work on your home machine.

It is most advisable for you to create a folder (directory) on your machine where you can put the files needed for your assignments. This way, all work for this course will be in the same place when you go to look for it.


Submission/Grading

Zip up the scenario

Zip up the Lab2 scenario to create a file named Lab2.zip

Submission of zip file

Follow the instructions here and submit your file to the Lab 2 assignment. Note that you can submit your files from any computer that has the zip file and a web-browser. If you are experienced problems with submitting in the past, you need to make sure that you get them resolved before the due date for this lab. NO submissions will be accepted via email under any circumstances.

Grading

There is no in-recitation assessment for this assignment. Grading will be based on the files you submit to Web-CAT. The grading guideline for this lab will be posted shortly (note the link on the left hand side of the page).

Due Date

Submissions for this assignment will close at 11:45pm on Friday, March 5th. No late submissions of this assignment will be accepted.


Lab authored by Adrienne Decker

CSE 113 - Spring 2010 - Footer

Page maintained by Adrienne Decker

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