Difference between revisions of "A fox moves in a random direction if they haven't eaten enough food that turn"
(→The Fox Class) |
|||
Line 19: | Line 19: | ||
return MoveFox; | return MoveFox; | ||
} | } | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | Find the line in the Fox class that displays the following message: | ||
+ | |||
+ | <syntaxhighlight lang=csharp> | ||
+ | Console.WriteLine(" Fox ages further due to lack of food."); | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | Add a line below this to set MoveFox to true: | ||
+ | |||
+ | <syntaxhighlight lang=csharp> | ||
+ | SetMoveFox(true); | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | or: | ||
+ | |||
+ | <syntaxhighlight lang=csharp> | ||
+ | MoveFox = true; | ||
</syntaxhighlight> | </syntaxhighlight> |
Revision as of 10:52, 25 May 2017
The Fox Class
Declare a new Boolean called MoveFox, this should be declared as private (you could make it simpler by declaring it public).
Then create a method to set this value.
Then create a method to get this value.
private bool MoveFox = false;
public void SetMoveFox(bool value)
{
MoveFox = value;
}
public bool GetMoveFox()
{
return MoveFox;
}
Find the line in the Fox class that displays the following message:
Console.WriteLine(" Fox ages further due to lack of food.");
Add a line below this to set MoveFox to true:
SetMoveFox(true);
or:
MoveFox = true;