Difference between revisions of "Add an option on the menu to find the largest warren"
(Created page with "== Finding the largest warren ==") |
(→Finding the largest warren) |
||
Line 1: | Line 1: | ||
== Finding the largest warren == | == Finding the largest warren == | ||
+ | new code: | ||
+ | <syntaxhighlight lang="csharp" line> | ||
+ | if (menuOption == 5) | ||
+ | { | ||
+ | int maxWarrenCheck = 0; | ||
+ | int currentX = 0; | ||
+ | int currentY = 0; | ||
+ | for (int a = 0; a < LandscapeSize; a++) | ||
+ | { | ||
+ | for (int b = 0; b < LandscapeSize; b++) | ||
+ | { | ||
+ | if (Landscape[a, b].Warren != null && Landscape[a, b].Warren.GetRabbitCount() > maxWarrenCheck) | ||
+ | { | ||
+ | maxWarrenCheck = Landscape[a, b].Warren.GetRabbitCount(); | ||
+ | currentX = a; | ||
+ | currentY = b; | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | Console.WriteLine("Max warren is at {0},{1} and is {2} rabbits large", currentX, currentY, maxWarrenCheck); | ||
+ | </syntaxhighlight> |
Revision as of 13:49, 14 March 2017
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);