コード例 #1
0
        public static void RefactorPotatoStatements()
        {
            Potato potato = new Potato();

            if (potato != null)
            {
                bool notPeeled = !potato.IsPeeled;
                bool notRotten = !potato.IsRotten;

                if (notPeeled && notRotten)
                {
                    potato.Cook();
                }
            }
        }
コード例 #2
0
        public static void RefactorPotatoStatements()
        {
            Potato potato = new Potato();

            if (potato != null)
            {
                bool notPeeled = !potato.IsPeeled;
                bool notRotten = !potato.IsRotten;

                if (notPeeled && notRotten)
                {
                    potato.Cook();
                }
            }
        }
コード例 #3
0
        public static void Main()
        {
            /*
            Potato potato;
            //...
            if (potato != null)
            if(!potato.HasNotBeenPeeled && !potato.IsRotten)
            Cook(potato);
            */
            Potato potato = new Potato();

            // ....
            if (potato != null)
            {
                bool notPeeled = !potato.IsPeeled;
                bool notRotten = !potato.IsRotten;

                if (notPeeled && notRotten)
                {
                    potato.Cook();
                }
            }

            /*
            if (x >= MIN_X && (x =< MAX_X && ((MAX_Y >= y &&
            MIN_Y <= y) && !shouldNotVisitCell)))
            {
                VisitCell();
            }
            */
            const int MinX = 5;
            const int MaxX = 15;
            const int MinY = 5;
            const int MaxY = 15;

            int x = 7;
            int y = 8;

            bool shouldVisitCell = true;

            if (shouldVisitCell && IsInRange(x, MinX, MaxX) && IsInRange(y, MinY, MaxY))
            {
                VisitCell();
            }
        }
コード例 #4
0
        public static void Main()
        {
            /*
             * Potato potato;
             * //...
             * if (potato != null)
             * if(!potato.HasNotBeenPeeled && !potato.IsRotten)
             * Cook(potato);
             */
            Potato potato = new Potato();

            // ....
            if (potato != null)
            {
                bool notPeeled = !potato.IsPeeled;
                bool notRotten = !potato.IsRotten;

                if (notPeeled && notRotten)
                {
                    potato.Cook();
                }
            }

            /*
             * if (x >= MIN_X && (x =< MAX_X && ((MAX_Y >= y &&
             * MIN_Y <= y) && !shouldNotVisitCell)))
             * {
             *  VisitCell();
             * }
             */
            const int MinX = 5;
            const int MaxX = 15;
            const int MinY = 5;
            const int MaxY = 15;

            int x = 7;
            int y = 8;

            bool shouldVisitCell = true;

            if (shouldVisitCell && IsInRange(x, MinX, MaxX) && IsInRange(y, MinY, MaxY))
            {
                VisitCell();
            }
        }
コード例 #5
0
        public static void Main()
        {
            var potato = new Potato(15);

            if (potato.IsPeeled == false)
            {
                throw new Exception("The potato is not peeled!");
            }

            if (potato.IsRotten == true)
            {
                throw new Exception("The potato is rotten!");
            }

            if (potato != null && potato.IsPeeled && !potato.IsRotten)
            {
                potato.Cook();
            }
        }