Comparing Conversion Operators
Conversion Member Functions
Signature Matching Algorithm
Unary Binary Overloading
friend Function Usage
friend Function - Quiz
Define Class Inheritance
public Inheritance - Quiz
Reference Typing Conversions
Guidelines Virtual Functions
Virtual Function - Selection
Virtual Function - Exercise
Abstract Classes (L12)
Base Class Reference
Reinterpret const cast (L13)
Dynamic cast Operator
throw C++ Exception
Pure Polymorphism Conclusion
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.