Created
March 12, 2010 02:13
-
-
Save jmeridth/329970 to your computer and use it in GitHub Desktop.
funny c# object hierarchy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public abstract class AbstractJMClassFactory | |
{ | |
public abstract AbstractJMClass CreateHappyJM(); | |
public abstract AbstractJMClass CreateAngryJM(); | |
public abstract AbstractJMClass CreateHungryJM(); | |
} | |
public class ConcreteJMClassFactory: AbstractJMClassFactory { | |
public override AbstractJMClass CreateHappyJM() | |
{ | |
return new HappyJMClass(); | |
} | |
public override AbstractJMClass CreateAngryJM() | |
{ | |
return new AngryJMClass(); | |
} | |
public override AbstractJMClass CreateAngryJM() | |
{ | |
return new HungryJMClass(); | |
} | |
} | |
public abstract class AbstractJMClass { | |
public abstract void emit(); | |
} | |
public class HappyJMClass: AbstractJMClass | |
{ | |
private string[] responses; | |
public HappyJMClass() | |
{ | |
responses = new string[5] { "Hai guise! Write more tests! LOL", | |
"Have you finished your tests yet? ;)", | |
"Don't forget to verify your tickets ^_-", | |
"It's CATURDAY! (did you write some tests)?", | |
"I'm working from home, I ran out of clean pants! Also, write tests! :D" | |
}; | |
} | |
public override void emit() | |
{ | |
Random r_val = new Random(); | |
Console.WriteLine(responses[r_val.next(0,4)]); | |
} | |
} | |
public class AngryJMClass: AbstractJMClass | |
{ | |
private string[] responses; | |
public AngryJMClass() | |
{ | |
responses = new string[5] { "YOUR COMMIT BROKE THE BUILD! AGNES WILL CRUSH YOU! (fix your tests >:( )", | |
"Your test coverage is made of failure. JASON SMASH >:( ", | |
"I've said it once, I'll say it again. Today's the last day of the release, VERIFY SOME COMMITTED TICKETS! >:(", | |
"DAMMIT MAJOR!", | |
"I'm working from home, I can't stand to even look at you people anymore. >:(" | |
}; | |
} | |
public override void emit() | |
{ | |
Random r_val = new Random(); | |
Console.WriteLine(responses[r_val.next(0,4)]); | |
} | |
} | |
public class HungryJMClass: AbstractJMClass | |
{ | |
private string[] responses; | |
public HungryJMClass() | |
{ | |
responses = new string[5] { "Write more tests, then get in my belly.", | |
"I was a bit hungry after writing those tests, so I roasted Chris and Dietz. Hope no one misses them.", | |
"Don't forget to verify your tickets, so we can go eat.", | |
"It's lunch time! (did you write some tests)?", | |
"I'm working from home, my wife just finished Christmas dinner!" | |
}; | |
} | |
public override void emit() | |
{ | |
Random r_val = new Random(); | |
Console.WriteLine(responses[r_val.next(0,4)]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment