Last active
January 5, 2023 05:41
-
-
Save LuviKunG/f2eeb10236942199bd732c64bca1a103 to your computer and use it in GitHub Desktop.
WTF am I doing...? (Please ignore this gist, It's just a drunk code)
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; | |
internal class Human | |
{ | |
private string name; | |
private Hand[] hands; | |
private Human() | |
{ | |
hands = new Hand[2] | |
{ | |
new Hand(Hand.Side.Left), | |
new Hand(Hand.Side.Right) | |
}; | |
} | |
internal Human(string name) : this() | |
{ | |
this.name = name; | |
} | |
public string GetName() => name; | |
public Hand GetHand(Hand.Side side) | |
{ | |
foreach (Hand hand in hands) | |
if (hand.GetSide() == side) | |
return hand; | |
return null; | |
} | |
} | |
internal class Hand | |
{ | |
internal enum Side : byte | |
{ | |
Left, | |
Right | |
} | |
private Side side; | |
private Finger[] fingers; | |
private Hand() | |
{ | |
fingers = new Finger[5] | |
{ | |
new Finger(Finger.Index.Thumb), | |
new Finger(Finger.Index.Index), | |
new Finger(Finger.Index.Middle), | |
new Finger(Finger.Index.Ring), | |
new Finger(Finger.Index.Pinkie) | |
}; | |
} | |
internal Hand(Side side) : this() | |
{ | |
this.side = side; | |
} | |
public Side GetSide() => side; | |
public Finger GetFinger(Finger.Index index) | |
{ | |
foreach (Finger finger in fingers) | |
if (finger.GetIndex() == index) | |
return finger; | |
return null; | |
} | |
} | |
internal class Finger | |
{ | |
internal enum Index : byte { Thumb, Index, Middle, Ring, Pinkie } | |
private Index index; | |
private bool isShow; | |
private Finger() | |
{ | |
isShow = false; | |
} | |
internal Finger(Index index) : this() | |
{ | |
this.index = index; | |
} | |
public Index GetIndex() => index; | |
public bool IsShow() => isShow; | |
public void Show() => isShow = true; | |
public void Hide() => isShow = false; | |
} | |
public static class World | |
{ | |
public static int Main(string[] args) | |
{ | |
Console.Title = "Welcome to the world!"; | |
bool hasParams = args != null && args.Length > 0; | |
Human me = new Human("LuviKunG"); | |
Console.WriteLine($"My name is {me.GetName()}"); | |
Hand myLeftHand = me.GetHand(Hand.Side.Left); | |
Finger myMiddleFinger = myLeftHand.GetFinger(Finger.Index.Middle); | |
myMiddleFinger.Show(); | |
if (myMiddleFinger.IsShow()) | |
Console.WriteLine("And I show my middle finger."); | |
else | |
Console.WriteLine("And why I can't show my middle finger!? So sad..."); | |
if (hasParams) | |
Console.WriteLine("I don't even care about what are you sending params!"); | |
Console.WriteLine("Welcome to C#."); | |
Console.ReadKey(); | |
return hasParams ? 1 : 0; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
My life is done.