public void ShowSequence() { int last = _receivedSequence.Last(); _printer.WriteLine(string.Format(Constant.NUMERIC_SEQUENCE_RESULT, _maxValue), (int)Color.Yellow); Console.ForegroundColor = ConsoleColor.White; foreach (var number in _receivedSequence) { if (!number.Equals(last)) { _printer.Write(string.Format("{0}, \t", number)); } else { _printer.WriteLine(string.Format("{0}\t", number)); } } Console.ResetColor(); }
public override void Initialize(string number) { IOutsidePrinter printer = _allFactories.TasksLibFactory.CreatePrinter(); try { IConverter converter = _allFactories.TasksLibFactory.CreateConverter(); IValidator validator = _allFactories.ValidatorFactory.CreateValidator(); int convertedNumber = converter.TryParseToInt(number); if (convertedNumber == -1) { printer.WriteLine(Constant.INT_WRONG_TYPE, (int)Color.Red); printer.ShowInstruction(); Environment.Exit(-1); } if (!validator.CheckIntOnPositive(convertedNumber)) { printer.WriteLine(Constant.WRONG_BOUNDARIES, (int)Color.Red); printer.ShowInstruction(); Environment.Exit(-1); } ISequence sequence = _allFactories.SequenceFactory.CreateSequence(); ISequenceViewer viewer = _allFactories.SequenceFactory.CreateSequenceViewer(sequence.GetSequence(convertedNumber), printer, convertedNumber); viewer.ShowSequence(); } catch (ArgumentException ex) { printer.WriteLine(string.Format(Constant.ERROR_OCCURED, ex.Message), (int)Color.Red); throw; } }