Comparing Conversion Operators
Conversion Member Functions
Signature Matching Algorithm
Unary Binary Overloading
friend Function Usage
friend Function - Quiz
public Inheritance - Quiz
Virtual Function - Exercise
next empty Squares - Exercise
Creating next() for empty squares
Write a version of
that determines how to fill an empty square in the simulation.
Here are some fairly simple rules for determining how to fill an empty square:
Check if there are other foxes nearby. If there are at least two of them, fill the square with a fox.
If the square is still empty, check if there are any other rabbits nearby. If there are at least two, fill the square with a rabbit.
If the square is still empty, check if there is any grass nearby. If there is, fill the square with grass.
If the square is still empty, leave it that way.
Remember, you can use
to determine how many of a particular lifeform are nearby the current square.
The code you've examined so far for the
is also available in a file named living.cpp, which can be found in the compressed course download file.
Paste your code below and click the
button when you are ready to submit this exercise.