public static void ConnectClient(Socket clientSocket) { var clientCalcIO = new TCPCalcIO(clientSocket, _consoleCalcIO); _clientCalcIO.Add(clientCalcIO); var expParser = new ExpressionParser(); var pathReader = new PathReader(); var firstOperation = new SaveNumberOperation(); var operations = new List <IOperation> { new AddOperation(), new SubstractOperation(), new DivideOperation(), new MultiplyOperation(), new JumpOperation(), new ExitOperation(), new LoadOperation(), new SaveOperation() }; var inputParser = new CalcInputParser(clientCalcIO); var mathBuffer = new MathBuffer(clientCalcIO); var history = new OperationsHistory(); var storage = new ProcessorStorageFilesWork(mathBuffer, clientCalcIO, history, expParser, pathReader, inputParser); var processor = new OperationsProcessor(storage, operations, firstOperation); processor.OperationPreReadAction += () => history.Update(processor, storage); var thread = new Thread(new ThreadStart(processor.Start)); _clientThreads.Add(thread); thread.Start(); }
/// <summary> /// Perform subtraction and store operation in history. /// </summary> public void Subtraction() { DisplayNumber = FirstOperand - SecondOperand; OperationsHistory.Insert(0, string.Format(FirstOperand + " - " + SecondOperand + " =\n" + DisplayNumber + "\n\n")); FirstOperand = DisplayNumber; }
/// <summary> /// Perform multiplication and store operation in history. /// </summary> public void Multiplication() { DisplayNumber = FirstOperand * SecondOperand; OperationsHistory.Insert(0, string.Format(FirstOperand + " \u00d7 " + SecondOperand + " =\n" + DisplayNumber + "\n\n")); FirstOperand = DisplayNumber; }
/// <summary> /// Perform division and store operation in history. /// </summary> public void Division() { DisplayNumber = FirstOperand / SecondOperand; OperationsHistory.Insert(0, string.Format(FirstOperand + " \u00f7 " + SecondOperand + " =\n" + DisplayNumber + "\n\n")); FirstOperand = DisplayNumber; }
/// <summary> /// Display calculator history. /// </summary> private void HistoryClick() { if (!ViewingHistory) { HistoryText = OperationsHistory.ToString().TrimEnd('\n'); ViewingHistory = true; } else { ViewingHistory = false; } }
public string GetOperationReport(OperationsHistory o) { return($"Id={o.Id}, AccountId={o.AccountId}, CashSum={o.CashSum}, " + $"OperationDate={o.OperationDate}, Type={o.OperationType}"); }