CountPlants - AS 2017
The Code
static void CountPlants(char[,] Field)
{
int NumberOfPlants = 0;
for (int Row = 0; Row < FIELDLENGTH; Row++)
{
for (int Column = 0; Column < FIELDWIDTH; Column++)
{
if (Field[Row, Column] == PLANT)
{
NumberOfPlants++;
}
}
}
if (NumberOfPlants == 1)
{
Console.WriteLine("There is 1 plant growing");
}
else
{
Console.WriteLine("There are " + NumberOfPlants + " plants growing");
}
}