1 / 5

Adding Lobsters

Adding Lobsters. Mrs. C. Furman August 23, 2010. Exercise. Add a new class to your scenario. A Lobster would be a subclass of what class? Create a Lobster class and give it the prepared Lobster image. What will the Lobster do when it is placed in the World?. Program Lobster to Eat Crab.

Download Presentation

Adding Lobsters

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Adding Lobsters Mrs. C. Furman August 23, 2010

  2. Exercise • Add a new class to your scenario. • A Lobster would be a subclass of what class? • Create a Lobster class and give it the prepared Lobster image. • What will the Lobster do when it is placed in the World?

  3. Program Lobster to Eat Crab • Add a method to lookForCrab() that will look for a crab and eat it. This method will be similar to crab’s lookForWorm() method. • Add a method to turnAtEdge(), this should be identical to crabs, so you can copy and paste it.

  4. Lobster Programming Cont. • Add a randomTurn() method that is like crab. Copy and paste it • Add a act method that calls lookForCrab, turnAtEdge, randomTurn and move.

  5. Exercise • Run the program and add a crab, 3 lobsters and many worms into the World. • Is the crab able to eat all the worms before it is eaten by a Lobster?

More Related