Thread: Enjoy a laugh at my expense (Coding mischief)

  1. #1
    Registered User Aran's Avatar
    Join Date
    Aug 2001
    Posts
    1,301

    Enjoy a laugh at my expense (Coding mischief)

    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:

    Code:
            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.

  2. #2
    Registered User NeonBlack's Avatar
    Join Date
    Nov 2007
    Posts
    431
    Well this is just ha-LARIOUS!

    Who says programmers have no sense of humor?
    I copied it from the last program in which I passed a parameter, which would have been pre-1989 I guess. - esbo

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. What beverage do you enjoy while coding?
    By Invincible in forum A Brief History of Cprogramming.com
    Replies: 28
    Last Post: 02-15-2002, 09:16 PM