コード例 #1
0
ファイル: IfStatements.cs プロジェクト: sabrie/TelerikAcademy
    static void Main()
    {
        // First "if statement" refactored
        Potato potato = new Patato();
        //...

        if (potato != null)
        {
            if (!potato.isRotten && potato.isPeeled)
            {
                Cook(potato);
            }
        }

        // Second "if statement" refactored
        const int MIN_ROW = 10;
        const int MAX_ROW = 20;
        const int MIN_COL = 10;
        const int MAX_COL = 20;
        int currentRow = 12;
        int currentCol = 15;
        bool isRowInRange = IsInRange(currentRow, MIN_ROW, MAX_ROW);
        bool isColInRange = IsInRange(currentCol, MIN_COL, MAX_COL);
        bool[,] isVisited = new bool[MAX_ROW, MAX_COL];

        if (isRowInRange && isColInRange && !isVisited[currentRow, currentCol])
        {
            VisitCell(currentRow, currentCol);
            isVisited[currentRow, currentCol] = true;
        }
    }
コード例 #2
0
    static void Main(string[] args)
    {
        //if statement one
        Potato potato = new Patato();
        bool isPatatoGoodForCook = !potato.HasNotBeenPeeled && !potato.IsRotten;
        if (potato != null && isPatatoGoodForCook)
        {
            Cook(potato);
        }

        //if statement two
        bool isXInTheRange = x >= MIN_X && x =< MAX_X;
        bool isYInTheRange = y >= MIN_Y && y =< MAX_Y;
        bool isCellGoodForVisit = !shouldNotVisitCell;
        if (isXInTheRange && isYInTheRange && isCellGoodForVisit)
        {
            VisitCell();
        }
    }
コード例 #3
0
ファイル: KitchenDemo.cs プロジェクト: Plugarov/Telerik-Repo
        static void Main(string[] args)
        {
            IVegetable carrot = new Carrot();
            IVegetable patato = new Patato();
            IVegetable paper  = new Paper();

            IVegetable vegetables = new Vegetables();

            IAppearance bowl    = new Bowl();
            IAppearance steamer = new Steamer();

            Chef chef = new Chef();

            chef.Wash();
            chef.Cut();
            chef.Prepare(bowl);
            chef.Cook(steamer);
            chef.Serve();
        }
コード例 #4
0
    static void Main(string[] args)
    {
        //if statement one
        Potato potato = new Patato();
        bool   isPatatoGoodForCook = !potato.HasNotBeenPeeled && !potato.IsRotten;

        if (potato != null && isPatatoGoodForCook)
        {
            Cook(potato);
        }

        //if statement two
        bool isXInTheRange      = x >= MIN_X && x = < MAX_X;
        bool isYInTheRange      = y >= MIN_Y && y = < MAX_Y;
        bool isCellGoodForVisit = !shouldNotVisitCell;

        if (isXInTheRange && isYInTheRange && isCellGoodForVisit)
        {
            VisitCell();
        }
    }