Problem

(Case Study) GridWorld’s firstProject file contains the BugRunner driver:public class BugR...

(Case Study) GridWorld’s

firstProject
file contains the
BugRunner
driver:

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 BugRunner

BugRunner
starts by creating an instance of
ActorWorld
called
world. ActorWorld’s
constructor immediately creates a 10 by 10
BoundedGrid.
Next,
BugRunner
asks the
ActorWorld
object to add a new
Bug
at a random location, and then add 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.

Draw an abbreviated UML class diagram that contains all classes identified in the above two paragraphs, except for the

BugRunner
class. 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
ActorWorld
and
WorldFrame,
use simple bidirectional association, like this:

Or use bidirectional dependence, like this:

Step-by-Step Solution

Request Professional Solution

Request Solution!

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.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 13
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT