Exemple #1
0
        /* String to int */
        public static int convert(string boyut)
        {
            /**
             * Input extraction
             */
            ExtractInput extract = new ExtractInput();

            /* Handle integers from string */
            int dizi_boyutu = extract.extractInput(boyut);

            /* Return size of array */
            return(dizi_boyutu);
        }
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 */
            }
        }