public Spreadsheet(int maxSize)
 {
     _communicator          = new Communicator();
     _transformator         = new Transformator();
     _reversePolishNotation = new ReversePolishNotation();
     _maxSize = maxSize;
     Cells    = new Cell[_maxSize, _maxSize];
     for (int i = 0; i < _maxSize; i++)
     {
         for (int j = 0; j < _maxSize; j++)
         {
             Cells[i, j] = new Cell();
         }
     }
 }
Example #2
0
        public void StartDialogWithUser(Cell[,] cells, ReversePolishNotation reversePolishNotation, Transformator transformator, int size)
        {
            Console.WriteLine();
            PrintPossibleOptions();
            while (true)
            {
                char command = Console.ReadKey().KeyChar;
                Console.WriteLine();
                switch (command)
                {
                case 'q':
                    Console.WriteLine("Ty for using our Spreadsheet. See you later");
                    return;

                case 'c':
                    Console.WriteLine("Type your expression");
                    ReadAndCalculateExpression(cells, reversePolishNotation, transformator);
                    break;

                case 'u':
                    Console.WriteLine("Updating values is not suported yet");
                    break;

                case 'v':
                    Console.WriteLine("Here you go");
                    PrintSpreadsheetValues(cells, size);
                    break;

                case 'e':
                    Console.WriteLine("Here you go");
                    PrintSpreadsheetExpressions(cells, size);
                    break;

                default:
                    Console.WriteLine("Something goes wrong. try again");
                    PrintPossibleOptions();
                    break;
                }
            }
        }
Example #3
0
        public void ReadAndCalculateExpression(Cell[,] cells, ReversePolishNotation reversePolishNotation, Transformator transformator)
        {
            string userExpression = Console.ReadLine();
            double result         = transformator.CalculateExpressionWithCoordinates(userExpression, cells, reversePolishNotation);

            Console.WriteLine(result.ToString());
        }