Exemplo n.º 1
0
        override public string ToString()
        {
            string s             = "";
            int    numberOfDigit = (int)Math.Floor(Math.Log10(SquareOrder) + 1);

            for (int row = 0; row < SquareOrder; row++)
            {
                for (int column = 0; column < SquareOrder; column++)
                {
                    int number = PlayGrid.Find(cell => cell.X == column && cell.Y == row).Value;
                    if (number != Int32.MinValue)
                    {
                        s = s + padCentre(number.ToString(), numberOfDigit);
                    }
                    else
                    {
                        s = s + padCentre("", numberOfDigit);
                    }
                    s = s + "|";
                }
                s = s.Remove(s.Length - 1);
                s = s + " -> " + getCostRow(row);
                s = s + System.Environment.NewLine;
            }
            for (int column = 0; column < SquareOrder; column++)
            {
                s = s + padCentre("v", numberOfDigit) + " ";
            }
            s = s + System.Environment.NewLine;
            for (int column = 0; column < SquareOrder; column++)
            {
                s = s + padCentre(getCostColumn(column).ToString(), numberOfDigit) + "|";
            }
            s = s.Remove(s.Length - 1);
            s = s + " -> " + getCost() + System.Environment.NewLine;
            return(s);
        }