Difference between revisions of "CreateNewField - AS 2017"

From TRCCompSci - AQA Computer Science
Jump to: navigation, search
(Created page with "==The Code== <syntaxhighlight lang=Csharp> </syntaxhighlight> ==Explanation==")
 
 
Line 2: Line 2:
  
 
<syntaxhighlight lang=Csharp>
 
<syntaxhighlight lang=Csharp>
 
+
static void CreateNewField(char[,] Field)
 +
{
 +
    int Row = 0;
 +
    int Column = 0;
 +
    for (Row = 0; Row < FIELDLENGTH; Row++)
 +
    {
 +
        for (Column = 0; Column < FIELDWIDTH; Column++)
 +
        {
 +
            Field[Row, Column] = SOIL;
 +
        }
 +
    }
 +
    Row = FIELDLENGTH / 2;
 +
    Column = FIELDWIDTH / 2;
 +
    Field[Row, Column] = SEED;
 +
}
 
</syntaxhighlight>
 
</syntaxhighlight>
  
 
==Explanation==
 
==Explanation==

Latest revision as of 09:25, 3 March 2017

The Code

static void CreateNewField(char[,] Field)
{
    int Row = 0;
    int Column = 0;
    for (Row = 0; Row < FIELDLENGTH; Row++)
    {
        for (Column = 0; Column < FIELDWIDTH; Column++)
        {
            Field[Row, Column] = SOIL;
        }
    }
    Row = FIELDLENGTH / 2;
    Column = FIELDWIDTH / 2;
    Field[Row, Column] = SEED;
}

Explanation