public void Cook()
        {
            Potato potato = this.GetPotato();

            this.Peel(potato);
            this.Cut(potato);
            Carrot carrot = this.GetCarrot();

            this.Peel(carrot);
            this.Cut(carrot);
            Bowl bowl = this.GetBowl();

            bowl.Add(carrot);
            bowl.Add(potato);
        }
Example #2
0
        public void Cook()
        {
            Bowl bowl = GetBowl();

            Potato potato = GetPotato();

            Peel(potato);
            Cut(potato);
            bowl.Add(potato);

            Carrot carrot = GetCarrot();

            Peel(carrot);
            Cut(carrot);
            bowl.Add(carrot);
        }
        void firstStatement(Potato potato)
        {
            //Potato potato;
            ////...
            //if (potato != null)
            //    if (!potato.HasNotBeenPeeled && !potato.IsRotten)
            //        Cook(potato);

            if (potato != null)
            {
                if (!(potato.HasNotBeenPeeled && potato.IsRotten))
                {
                    potato.Cook();
                }
            }
        }
        public static void Main()
        {
            //01. Task
            Chef chef = new Chef();
            chef.Cook();

            //02. Task
            Potato potato;

            potato = new Potato();

            if (potato != null)
            {
                if (potato.IsPeeled && !potato.IsRotten)
                {
                    chef.Cook(potato);
                }
            }
        }
Example #5
0
        public static void RefactorFirstIf()
        {
            Potato potato = new Potato();
            potato.Peel();

            if (potato != null)
            {
                // This is how i thing is corret to be
                if (potato.HasBeenPeeled || potato.IsFresh)
                {
                    Cook(potato);
                }

                /*
                // This is one of the De Morgan’s laws
                if(!(potato.HasNotBeenPeeled || potato.IsRotten))
                {
                    Cook(potato);
                }
                */
            }
        }
Example #6
0
 private Potato GetPotato()
 {
     Potato potato = new Potato();
     return potato;
 }
Example #7
0
 private static void Cook(Potato potato)
 {
     Console.WriteLine("Cooking {0}", potato);
 }