Last active
March 1, 2016 01:45
-
-
Save sbarisic/6fbb8d45761ec13316f7 to your computer and use it in GitHub Desktop.
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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using System.Runtime.InteropServices; | |
using System.Threading; | |
namespace BuzzeFizz { | |
interface IFizzeBuzzTitleInterface { | |
string GetFizzeBuzzTitleInterfaceForDivisor(int Div); | |
} | |
class BuzzeGetter : IFizzeBuzzTitleInterface { | |
public string GetFizzeBuzzTitleInterfaceForDivisor(int Div) { | |
if (Div == 5) | |
return "Buzz"; | |
throw new Exception(new Exception().ToString()); | |
} | |
} | |
class FizzeGetter : IFizzeBuzzTitleInterface { | |
public string GetFizzeBuzzTitleInterfaceForDivisor(int Div) { | |
if (Div == 3) | |
return "Fizze"; | |
throw new Exception(new Exception().ToString()); | |
} | |
} | |
class EmptyObjectArrayFactory { | |
public static EmptyObjectArrayFactory Singleton = new EmptyObjectArrayFactory(); | |
public object[] CreateEmptyObjectArray() { | |
return new object[] { }; | |
} | |
public EmptyObjectArrayManipulator GetEmptyObjectArrayManipulator() { | |
return new EmptyObjectArrayManipulator(); | |
} | |
} | |
class EmptyObjectArrayManipulator { | |
public object[] AppendObjectToEmptyObjectArray(object[] EmptyObjectArray, object Object) { | |
object[] EmptyObjectArray2 = new object[EmptyObjectArray.Length + 1]; | |
Array.Copy(EmptyObjectArray, EmptyObjectArray2, EmptyObjectArray.Length); | |
EmptyObjectArray2[EmptyObjectArray2.Length - 1] = Object; | |
return EmptyObjectArray2; | |
} | |
} | |
class Program { | |
static HashSet<IFizzeBuzzTitleInterface> FizzeBuzzTitleThingGetterEnumHashsetthing; | |
static int FizzeBuzzInteger; | |
static bool DivisibilityReturnValue; | |
static void Main(string[] args) { | |
FizzeBuzzTitleThingGetterEnumHashsetthing = new HashSet<IFizzeBuzzTitleInterface>(); | |
FizzeBuzzTitleThingGetterEnumHashsetthing.Add(new FizzeGetter()); | |
FizzeBuzzTitleThingGetterEnumHashsetthing.Add(new BuzzeGetter()); | |
new Thread(() => typeof(Program).GetMethod("FizzThread").Invoke(null, | |
EmptyObjectArrayFactory.Singleton.GetEmptyObjectArrayManipulator().AppendObjectToEmptyObjectArray( | |
EmptyObjectArrayFactory.Singleton.CreateEmptyObjectArray(), typeof(Program).GetMethod("FizzThread").GetParameters()[0].DefaultValue))).Start(); | |
Console.ReadLine(); | |
} | |
static string GetTitleThingWhatever(int Div) { | |
foreach (IFizzeBuzzTitleInterface FB in FizzeBuzzTitleThingGetterEnumHashsetthing) { | |
try { | |
return FB.GetFizzeBuzzTitleInterfaceForDivisor(Div); | |
} catch (Exception UnusedException) { | |
} | |
} | |
throw new Exception("Potatoes aren't allowed in code"); | |
} | |
public static void FizzThread(int I = 0) { | |
if (I > 20) | |
return; | |
new Thread(() => FizzThread(I + 1)).Start(); | |
new Thread(() => ThreadBuzz(I)).Start(); | |
} | |
static void ThreadBuzz(int I) { | |
Thread.Sleep(I * 500); | |
bool Fizze, Buzz; | |
Fizze = Buzz = false; | |
Thread CheckDivisibility = new Thread(() => Divisible(3)); | |
FizzeBuzzInteger = I; | |
CheckDivisibility.Start(); | |
while (CheckDivisibility.ThreadState != ThreadState.Stopped) | |
; | |
Fizze = DivisibilityReturnValue; | |
CheckDivisibility = new Thread(() => Divisible(5)); | |
CheckDivisibility.Start(); | |
while (CheckDivisibility.ThreadState != ThreadState.Stopped) | |
; | |
Buzz = DivisibilityReturnValue; | |
if (Fizze || Buzz) { | |
if (Fizze) | |
Console.Write(GetTitleThingWhatever(3)); | |
if (Buzz) | |
Console.Write(GetTitleThingWhatever(5)); | |
} else | |
Console.Write(FizzeBuzzInteger); | |
Console.WriteLine(); | |
} | |
static void Divisible(int Num) { | |
DivisibilityReturnValue = DateTime.IsLeapYear(2015 + GetEarthDiameterForBool(FizzeBuzzInteger % Num == 0)); | |
} | |
static int GetEarthDiameterForBool(bool B) { | |
if (B) | |
return 1; | |
return 0; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment