(Case Study) GridWorld’s
firstProjectfile contains the
BugRunnerdriver:
public class BugRunner{ public static void main(String[] args) { ActorWorld world = new ActorWorld() ; world.add(new Bug()); world.add(new Rock()); world.show() ; } // end main} // end class BugRunnerBugRunnerstarts by creating an instance of
ActorWorldcalled
world. ActorWorld’sconstructor immediately creates a 10 by 10
BoundedGrid.Next,
BugRunnerasks the
ActorWorldobject to add a new
Bugat a random location, and then add a new
Rockat a different random location.
ActorWorld’s addmethod 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’slast statement calls
ActorWorld’sshow method. This
showmethod instantiates a
WorldFrame(a GUI window) with an argument referring back to the
ActorWorldobject.
WorldFrame’sconstructor instantiates a
GridPanel.Then it uses its reference to the
ActorWorldobject to get a reference to the
BoundedGrid,and it passes this
BoundedGridreference on to the new
GridPanel.
GridPanel’s drawOccupantsmethod uses this
BoundedGridreference to call
BoundedGrid’s getOccupiedLocationsmethod. This allows
GridPanel’s paintComponentmethod to put bug and rock images in their proper places each time it repaints the screen.
Draw an abbreviated UML class diagram that contains all classes identified in the above two paragraphs, except for the
BugRunnerclass. Use appropriate composition (black diamond) and aggregation (hollow diamond) links. Include multiplicity symbols where one of the multiplicities might be greater than unity. For the relationship between
ActorWorldand
WorldFrame,use simple bidirectional association, like this:
![]()
Or use bidirectional dependence, like this:
![]()
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.