Class Worm_and_Apple

Class Worm_and_Apple

java.lang.Object
   |
   +----Worm_and_Apple

public class Worm_and_Apple
extends Object
Program 6.3, from the textbook "Ada 95", rewritten for two Spiders named "worm" and "apple". Worm starts out at an arbitrary point in the Room, walks random distances similarly to "Drunken_Spider" (Program 7.7), until it reaches the Spider named "apple", in the center of the Room.
------------------------------------------------------------------
--| Displays distances between a worm and an apple.  The worm keeps reducing
--| the distance by its body length until it is close enough to bite the apple.
--| Author: Michael B. Feldman, The George Washington University
--| Last Modified: July 1995
------------------------------------------------------------------
  
Before the program runs, it asks the user to input the starting X and Y (pixel) coordinates of the Spider named "apple". The input prompt and response is displayed in a "System window" (which under Windows 95 looks like an MS-DOS window). Before responding to the prompt the user should move the System window to not overlap the drawing area (Room). If this is not done, hidden areas of Room will appear blank when Room is exposed later, because this program does not repaint the drawing area in response to window events.

Click on the "close button" (marked X) in the top right corner of the spider's window, to terminate the application.

See Also:
Spider, Room, AppFrame

Constructor Index

 o Worm_and_Apple()

Method Index

 o main(String[])

Constructors

 o Worm_and_Apple
  public Worm_and_Apple()

Methods

 o main
  public static void main(String args[]) throws IOException