Problem

The changes made in this section have removed the dependences (couplings) of the simulat...

The changes made in this section have removed the dependences (couplings) of the simulateOneStep method on the Fox and Rabbit classes. The Simulator class, however, is still coupled to Fox and Rabbit, because these classes are referenced in the populate method. There is no way to avoid this; when we create animal instances, we have to specify exactly what kind of animal to create.

This could be improved by splitting the Simulator into two classes: one class, Simulator, that runs the simulation and is completely decoupled from the concrete animal classes, and another class, PopulationGenerator (created and called by the simulator), that creates the population. Only this class is coupled to the concrete animal classes, making it easier for a maintenance programmer to find places where change is necessary when the application is extended. Try implementing this refactoring step. The PopulationGenerator class should also define the colors for each type of animal.

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
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