Enjoy a laugh at my expense (Coding mischief) [Archive] - C Board

PDA

View Full Version : Enjoy a laugh at my expense (Coding mischief)


Aran
03-22-2008, 02:28 PM
I'm writing a sim that currently builds families and ages the members, has them intermarry and reproduce. Here's the main method of the simulation:


static public void runTick()
{
Events.Add(Sim.numTicks + ": System population is " + Characters.Count + ".\n");
int i = 0;
Character c = Characters[i];
while (c != null)
{
try
{
if (c.runTick())
{
c = Characters[++i];
}
else
{
c = Characters[i];
}
}
catch (Exception e)
{
break;
}
}

Sim.numTicks++;
}


For those of you new to programming: NEVER do this. It's a terrible practice. I just did it to hack a way through modifying an Enumerable while I'm iterating through it.

NeonBlack
03-22-2008, 09:47 PM
Well this is just ha-LARIOUS!

Who says programmers have no sense of humor?