Exemple #1
0
        public static void setMove(int step)
        {
            for (int i = 0; i < step; i++)
            {
                switch (rotate)
                {
                case 0:
                    Araba.move(0, 1);
                    break;

                case 1:
                    Araba.move(-1, 0);
                    break;

                case 2:
                    Araba.move(0, -1);
                    break;

                case 3:
                    Araba.move(1, 0);
                    break;
                }
            }
        }
Exemple #2
0
        public static void splitDirectiveThenRun(string directives)
        {
            /*
             *  Split string from '+' (plus) char then check directive.
             */
            for (int i = 0; i < directives.Split('+').Length; i++)
            {
                /* Handle first loop */
                if (i == 0)
                {
                    /* Prepare map */
                    Harita.PrepareMap(directives.Split('+')[i]);
                }

                /* If is move directive */
                if (ExtractInput.checkMove(directives.Split('+')[i]))
                {
                    int move = ExtractInput.getMove(directives.Split('+')[i]);

                    Araba.setMove(move);

                    /* Debug point */
                    //Console.WriteLine(move);

                    continue;
                }
                else /* If ısn't moving action. */
                {
                    /* Command shortcut */
                    int command = Harita.convert(directives.Split('+')[i]);

                    /* Switch case skeleton */
                    switch (command)
                    {
                    case 1:     /* Set brush up */
                        Araba.setCarBrush(true);
                        continue;

                    case 2:     /* Set brush down */
                        Araba.setCarBrush(false);
                        continue;

                    case 3:     /* Turn right */
                        Araba.setCarRotate(-1);
                        continue;

                    case 4:     /* Turn left */
                        Araba.setCarRotate(1);
                        continue;

                    case 6:                       /* Jump */
                        Araba.setCarBrush(false); // Set brush up
                        Araba.setMove(3);
                        continue;

                    case 7:     /* Reverse route 180* degree. */
                        Araba.setCarRotate(-1);
                        Araba.setCarRotate(-1);
                        continue;

                    case 8:     /* Show map. */
                        Harita.ShowMap();
                        continue;

                    case 0:     /* Exit. */
                        break;
                    }
                }
                /* Switch case skeleton */
            }
        }