C Board  

Go Back   C Board > General Programming Boards > C# Programming

Reply
 
LinkBack Thread Tools Display Modes
Old 03-22-2008, 02:28 PM   #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.
Aran is offline   Reply With Quote
Old 03-22-2008, 09:47 PM   #2
Registered User
 
NeonBlack's Avatar
 
Join Date: Nov 2007
Posts: 248
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
NeonBlack is online now   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
What beverage do you enjoy while coding? Invincible A Brief History of Cprogramming.com 28 02-15-2002 09:16 PM


All times are GMT -6. The time now is 08:26 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22