A fox moves in a random direction if they haven't eaten enough food that turn

From TRCCompSci - AQA Computer Science
Revision as of 10:52, 25 May 2017 by Admin (talk | contribs) (The Fox Class)
Jump to: navigation, search

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;