Add an option on the menu to find the largest warren

From TRCCompSci - AQA Computer Science
Revision as of 13:49, 14 March 2017 by Alex1 (talk | contribs) (Finding the largest warren)
Jump to: navigation, search

Finding the largest warren

new code:

 1  
 2 if (menuOption == 5)
 3 {
 4    int maxWarrenCheck = 0;
 5    int currentX = 0;
 6    int currentY = 0;
 7       for (int a = 0; a < LandscapeSize; a++)
 8       {
 9          for (int b = 0; b < LandscapeSize; b++)
10          {
11             if (Landscape[a, b].Warren != null && Landscape[a, b].Warren.GetRabbitCount() > maxWarrenCheck)
12                             {
13                                 maxWarrenCheck = Landscape[a, b].Warren.GetRabbitCount();
14                                 currentX = a;
15                                 currentY = b;
16                             }
17                         }
18                     }
19                     Console.WriteLine("Max warren is at {0},{1} and is {2} rabbits large", currentX, currentY, maxWarrenCheck);