예제 #1
0
        static void Main(string[] args)
        {
            var list = new List <string> {
                "Martin"
            };
            var firtThingInList = list[0];

            var spouses = new Dictionary <MiniFigure, MiniFigure>();

            var todd       = new MiniFigure();
            var toddSpouse = new MiniFigure();

            spouses.Add(todd, toddSpouse); // Yay, we performed a minifigure wedding!!

            var spouseKeys = spouses.Keys;

            var success  = spouses.TryGetValue(todd, out MiniFigure toddRealSpouse);
            var canParse = Int32.TryParse("42", out var realInt);

            var tuple = new Tuple <string, int, MiniFigure>("Martin", 42, todd);

            var name   = tuple.Item1;
            var number = tuple.Item2;

            var martinExists = list.Exists(x => x == "Martin") && list.Capacity > 0 || list.Count > 0;

            if (martinExists)
            {
                DoSomething();
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            var miniFigure = new MiniFigure();

            miniFigure.Head = new YodaHead
            {
                EyeColor     = "Brown",
                HairColor    = "Blue",
                HasNose      = false,
                MouthIsOpen  = true,
                NumberOfEyes = 3,
            };

            var fatHead = new FatHead();

            fatHead.Talk();
            miniFigure.Head.Think();

            switch (miniFigure.Head)
            {
            case YodaHead h:
                h.Battle();
                break;
            }

            //fatHead.Size = HeadSize.Small;
        }
예제 #3
0
        static void Main(string[] args)
        {
            var head = new YodaHead
            {
                EyeColor     = "Brown",
                HairColor    = "Blue",
                HasNose      = false,
                NumberOfEyes = 3,
            };

            var torso = new YetiTorso();

            var legs = new ZombieLegs();

            var YodaYetiZombie = new MiniFigure(head, torso, legs);

            YodaYetiZombie.Battle();

            var fatHead     = new FatHead();
            var pirateTorso = new PirateTorso(HandType.Hook);
            var centaurLegs = new CentaurLegs();

            var fathEadedCentaurPirate = new MiniFigure(fatHead, pirateTorso, centaurLegs);

            fathEadedCentaurPirate.Battle();
        }
예제 #4
0
        static void Main(string[] args)
        {
            var list = new List <string> {
                "Martin"
            };
            var firstInList = list[0];

            var spouces = new Dictionary <MiniFigure, MiniFigure>();

            var todd  = new MiniFigure();
            var robin = new MiniFigure();

            spouces.Add(todd, robin);

            var spouceKeys = spouces.Keys;

            var success  = spouces.TryGetValue(todd, out MiniFigure robin);
            var canParse = Int32.TryParse("42", out var realInt);

            var name   = Tuple.Item1;
            var number = Tuple.Item2;

            var martinExists = list.Exists(x => x == "Martin") && list.Capacity > 0 || list.Count > 0;

            if (martinExists)
            {
                DoSomething();
            }
        }
예제 #5
0
        static void Main(string[] args)
        {
            var array = new string[5];

            var three = 3.ToString();

            /*if (true)
             *  DoSomething();*/

            //Same as below

            /* if (true)
             * {
             *   DoSomething();
             * }*/

            // Collections - Lists

            var list = new List <string>
            {
                "Martin",
                "Ben",
                three
            };

            list.Add("Nathan");

            Predicate <string> temp = x => x == "Martin";

            var martinExists = list.Exists(temp);

            // var dictionary = new Dictionary<int, string>();

            // Collections - Dictionary

            var spouses = new Dictionary <MiniFigure, MiniFigure>();

            var todd       = new MiniFigure();
            var toddSpouse = new MiniFigure();

            spouses.Add(todd, toddSpouse);
            // this example "just performed a wedding lol"
            var spouseKeys = spouses.Keys;

            // var toddRealSpouse; must be implicitly typed or initialized with a value

            //MiniFigure toddRealSpouse; same as what is listed below. it is being declared outside in this case.

            spouses.TryGetValue(todd, out MiniFigure toddRealSpouse);

            // Collections - Tuple
            var tuple = new Tuple <string, int, MiniFigure>("Martin", 42, todd);

            var name = tuple.Item1;
        }
예제 #6
0
 public override void Kick(MiniFigure minifigure)
 {
     Console.WriteLine($"Baby legs kicked {minifigure.Name}, the {minifigure.Description}.");
 }
예제 #7
0
 public virtual void Kick(MiniFigure minifigure)
 {
     Console.WriteLine($"The legs kicked {minifigure.Name}, the {minifigure.Description}.");
 }