Subroutines - Methods - 2017
Revision as of 13:57, 6 February 2017 by ThomasWard (talk | contribs) (Created page with "A subroutine is a name given to a block of code that can be called by name to perform the operation in the subroutine without having to copy the code it contains. If the subro...")
A subroutine is a name given to a block of code that can be called by name to perform the operation in the subroutine without having to copy the code it contains. If the subroutine is used to return a value and not just perform an operation, it is known as a function. The subroutine can be passed by a variable parameter if the data type is specified.
private void CreateNewFox()
{ int x, y; do { x = Rnd.Next(0, LandscapeSize); y = Rnd.Next(0, LandscapeSize); } while (Landscape[x, y].Fox != null); if (ShowDetail) { Console.WriteLine(" New Fox at (" + x + "," + y + ")"); } Landscape[x, y].Fox = new Fox(Variability); FoxCount++; }