Exemple #1
0
        private static PizzaParams ParseFromStream(TextReader reader)
        {
            string first = reader.ReadLine();

            string[]    lineParams = first.Split(' ');
            PizzaParams pizaParam  = new PizzaParams(int.Parse(lineParams[0]), int.Parse(lineParams[1]), int.Parse(lineParams[2]),
                                                     int.Parse(lineParams[3]));

            string line  = reader.ReadLine();
            int    count = 0;

            while (line != null)
            {
                char[] lineAsChar = line.ToCharArray();
                for (int i = 0; i < line.Length; i++)
                {
                    if (lineAsChar[i] == 'M')
                    {
                        pizaParam.PizzaIngredients[i, count] = Ingredient.Mushroom;
                    }
                    else
                    {
                        pizaParam.PizzaIngredients[i, count] = Ingredient.Tomato;
                    }
                }

                count++;
                line = reader.ReadLine();
            }

            return(pizaParam);
        }
Exemple #2
0
        public void PrintToConsole(PizzaParams pizzaParams, IEnumerable<PizzaSlice> slices)
        {
            CellToPrint[,] pizzaCells = new CellToPrint[pizzaParams.XLength, pizzaParams.YLength];
            for (int y = 0; y < pizzaParams.YLength; y++)
            {
                for (int x = 0; x < pizzaParams.XLength; x++)
                {
                    CellToPrint cell = new CellToPrint();
                    cell.color = ConsoleColor.Green;
                    cell.ingredient = pizzaParams.PizzaIngredients[x, y];
                    pizzaCells[x, y] = cell;
                }
            }

            foreach (PizzaSlice slice in slices)
            {
                ConsoleColor randomColor = GetColor();
                for (int y = slice.TopLeft.Y; y <= slice.BottomRight.Y; y++)
                {
                    for (int x = slice.TopLeft.X; x <= slice.BottomRight.X; x++)
                    {
                        if (pizzaCells[x, y].color != ConsoleColor.Green)
                        {
                            throw new Exception("das for gal");
                        }

                        pizzaCells[x, y].color = randomColor;
                    }
                }
            }

            for (int y = 0; y < pizzaParams.YLength; y++)
            {
                for (int x = 0; x < pizzaParams.XLength; x++)
                {
                    CellToPrint print = pizzaCells[x, y];
                    Console.ForegroundColor = print.color;
                    if (print.ingredient == Ingredient.Mushroom)
                    {
                        Console.Write('M');
                    }
                    else
                    {
                        Console.Write('T');
                    }
                }

                Console.Write("\n");
            }

			Console.ForegroundColor = ConsoleColor.White;
        }
Exemple #3
0
 public PizzaSolverBlat(PizzaParams pizza) : base(pizza)
 {
 }
 public PizzaSolverBasic(PizzaParams pizza) : base(pizza)
 {
 }
Exemple #5
0
 public PizzaSolverBase(PizzaParams pizza)
 {
     Pizza         = pizza;
     tomatoTable   = CreateCountTable(Ingredient.Tomato);
     mushroomTable = CreateCountTable(Ingredient.Mushroom);
 }