Question: GridWorlds firstProject file contains the BugRunner driver: BugRunner starts by creating an instance of ActorWorld named world. ActorWorlds constructor immediately creates a 10 10
GridWorld’s firstProject file contains the BugRunner driver:
![public class BugRunner { public static void main(String[] args) { ActorWorld world world.add(new Bug());](https://dsd5zvtm8ll6.cloudfront.net/images/question_images/1704/8/7/1/970659e48225c9271704871969095.jpg)
BugRunner starts by creating an instance of ActorWorld named world. ActorWorld’s constructor immediately creates a 10 × 10 BoundedGrid. Next, BugRunner asks the ActorWorld object to add a new Bug at a random location, and it then adds a new Rock at a different random location. ActorWorld’s add method tells each new occupant where it is supposed to go in the grid and then tells that occupant to put itself into the grid at that location.
BugRunner’s last statement calls ActorWorld’s show method. This show method instantiates a WorldFrame (a GUI window) with an argument referring back to the ActorWorld object.
WorldFrame’s constructor instantiates a GridPanel. Then it uses its reference to the ActorWorld object to get a reference to the BoundedGrid, and it passes this BoundedGrid reference on to the new GridPanel. GridPanel’s drawOccupants method uses this BoundedGrid reference to call BoundedGrid’s getOccupiedLocations method. This allows GridPanel’s paintComponent method to put bug and rock images in their proper places each time it repaints the screen.
Provide an abbreviated UML class diagram that contains all classes identified in the above two paragraphs, except for the BugRunner class. Use appropriate composition (filled diamond) and aggregation (hollow diamond) links. Include multiplicity symbols where one of the multiplicities might be greater than 1. For the relationship between ActorWorld and WorldFrame, use a simple bidirectional association, like this:
![]()
Or use a bidirectional dependence, like this:
![]()
public class BugRunner { public static void main(String[] args) { ActorWorld world world.add(new Bug()); world.add(new Rock()); world.show(); = new ActorWorld(); } // end main } // end class BugRunner
Step by Step Solution
3.45 Rating (155 Votes )
There are 3 Steps involved in it
lua Act... View full answer
Get step-by-step solutions from verified subject matter experts
