Exemple #1
0
        static void Main(string[] args)
        {
            var head = new ZoeHead
            {
                FacialExpression = "Smiling",
                Color            = LegoColor.Orange,
                EyeColor         = LegoColor.Green,
                Helmeted         = true
            };

            var legs = new AstronautLegs
            {
                HasPants = true,
                Shoes    = ShoeType.FlipFlops
            };

            var dtorso = new DadBodTorso
            {
                HandType    = HandType.Baby,
                ChiseledAbs = true,
                Shirted     = true
            };

            var atorso = new AstronautTorso()
            {
                HandType    = HandType.Baby,
                ChiseledAbs = true,
                Shirted     = true
            };


            atorso.Breathe();
            dtorso.Breathe();
            atorso.HandType    = HandType.Baby;
            dtorso.ChiseledAbs = false;

            var astronaut = new Astronaut("Space Person", "Janitor", head, atorso, legs);

            // var astronaut2 = new Astronaut("Space Lady", "Janitor", head, dtorso, legs);

            astronaut.DoYourJob(100);

            var casper = new Ghost("Casper", DateTime.Today)
                         // line 15 can also be stated with curly brackets, which would be called an object initializer
            {
                Friendly = true
            };

            casper.Spook();
            casper.Haunt("Whipstaff Manor");
            casper.Spook();

            var fatso = new Ghost("Fatso", new DateTime(1924, 12, 1))
                        // line 15 can also be stated with curly brackets, which would be called an object initializer
            {
                Friendly = false
            };

            fatso.Spook();
            fatso.Haunt("Whipstaff Manor");
            fatso.Spook();

            var torsos = new List <TorsoBase> {
                dtorso, atorso, new DadBodTorso()
            };

            foreach (var torso in torsos)
            {
                torso.Breathe();
                torso.Flex();

                switch (torso)
                {
                case DadBodTorso dbod:
                    dbod.ChangeTemperature("Hot");
                    break;
                }
            }

            var colorfulThings = new List <IColorful> {
                dtorso, atorso, new BabyLegs()
            };

            foreach (var colorfulThing in colorfulThings)
            {
                Console.WriteLine(colorfulThing.Color);

                switch (colorfulThing)
                {
                case IMoveable mover:
                    mover.Move(5);
                    break;
                }
            }
        }
Exemple #2
0
        static void Main(string[] args)
        {
            var head = new AstroHead()
            {
                FacialExpression = "Smiling",
                Color            = LegoColor.Yellow,
                EyeColor         = LegoColor.Green,
                Helmeted         = true
            };

            var atorso = new AstroTorso()
            {
                Hands        = HandType.Baby,
                ChiseledAbs  = true,
                HasShirt     = true,
                NumberOfArms = 3
            };

            var dtorso = new DadBodTorso()
            {
                Hands    = HandType.Tentacle,
                HasShirt = true,
                IsHairy  = false
            };

            var legs = new AstroLegs()
            {
                HasPants = true,
                Shoes    = ShoeType.MoonBoots
            };

            var astronaut = new Astronaut("Major Tom", "Janitor", head, dtorso, legs);

            astronaut.Promote();
            astronaut.DoYourJob();

            var casper = new Ghost("Casper", DateTime.Today)
            {
                IsFriendly = true,
                IsVisible  = true,
            };
            var stretch = new Ghost("Stretch", new DateTime(1895, 12, 1))
            {
                IsFriendly = false
            };

            casper.Spook();
            casper.Haunt("Whipstaff Manor");
            casper.Spook();

            var torsos = new List <TorsoBase>();

            torsos.Add(dtorso);
            torsos.Add(atorso);

            foreach (var torso in torsos)
            {
                torso.Breathe();
                torso.Flex();

                switch (torso)
                {
                case DadBodTorso dbod:
                    dbod.ChangeThermostat("Hot");
                    break;
                }
            }

            var colorfulThings = new List <IColorful> {
                dtorso, atorso, new Baby()
            };

            foreach (var colorfulThing in colorfulThings)
            {
                Console.WriteLine(colorfulThing.Color);

                switch (colorfulThing)
                {
                case IMoveable mover:
                    mover.Move(5);
                    break;
                }
            }

            Console.ReadKey();
        }
Exemple #3
0
        static void Main(string[] args)
        {
            var head = new ZoeHead
            {
                FacialExpression = "smiling",
                Color            = LegoColor.Orange,
                EyeColor         = LegoColor.Green,
                Helmeted         = true
            };

            var legs = new AstronautLegs
            {
                HasPants = true,
                Shoes    = ShoeType.Boots,
            };

            var atorso = new AstronautTorso
            {
                ChiseledAbs  = true,
                NumberOfArms = 4,
                Shirted      = true,
                HandType     = HandType.Xbuster
            };

            var dtorso = new AstronautTorso
            {
                ChiseledAbs  = true,
                NumberOfArms = 4,
                Shirted      = true,
                HandType     = HandType.Xbuster
            };

            var astronaut  = new Astronaut("Space Person", "Space Janitor", head, atorso, legs);
            var astronaut2 = new Astronaut("Space Lady", "Space Commander", head, dtorso, legs);

            astronaut.DoYourJob(25);
            astronaut2.DoYourJob(15);


            atorso.Breathe();
            dtorso.Breathe();

            // can't do this
            // astronaut.Job = "Commander";

            // also can't do this
            // astronaut.SuitedUp = false;

            var casper = new Ghost("Casper", DateTime.Today)
                         // this is an Object Initalizer
            {
                Friendly = true,
            };

            casper.Spook();
            casper.Haunt("Whipstaff Manor");
            casper.Spook();


            var torsos = new List <TorsoBase>();

            torsos.Add(dtorso);
            torsos.Add(atorso);

            foreach (var torso in torsos)
            {
                torso.Breathe();
                torso.Flex();
            }
        }