//Main loop public void Start(int doorsNum) { settingsProvider.ParseXML(); phraseProvider.ParseXML(settingsProvider.GetSetting("Language")); ioModule.WriteOutput(phraseProvider.GetMessage("Start")); int amountOfDoors = Convert.ToInt32(settingsProvider.GetSetting("DoorsCount")); int minDoorNum = Convert.ToInt32(settingsProvider.GetSetting("MinRandom")); int maxDoorNum = Convert.ToInt32(settingsProvider.GetSetting("MaxRandom")); if (maxDoorNum - minDoorNum > amountOfDoors) { doorsNumbers = doorsGenerator.GetDoorsNumbers(amountOfDoors, minDoorNum, maxDoorNum); PrintList(doorsNumbers); } else { throw new Exception("Incorrect settings. Amount of door less, than should be."); } ioModule.WriteOutput(phraseProvider.GetMessage("ExitCommand") + "\n"); string door; int curDoor; while (true) { door = ioModule.ReadInput(); if (door.ToLower().Equals("exit")) { ioModule.WriteOutput(phraseProvider.GetMessage("Exit")); break; } try { curDoor = Convert.ToInt32(door); if (curDoor == 0) { PreviousLevel(); } else if (doorsNumbers.Contains(curDoor)) { NextLevel(curDoor); } else { ioModule.WriteOutput(phraseProvider.GetMessage("IncorrectNumber")); } } catch (FormatException) { ioModule.WriteOutput(phraseProvider.GetMessage("InvalidCommand")); } catch (OverflowException) { ioModule.WriteOutput(phraseProvider.GetMessage("Overflow")); } } }
public void Start() { settingsProvider.ParseXML(); phraseProvider.ParseXML(settingsProvider.GetSetting("Language")); //Get language from settings file int boardLength = Convert.ToInt32(settingsProvider.GetSetting("Length")); //Get lenght of dashboard from settings file int boardWidth = Convert.ToInt32(settingsProvider.GetSetting("Width")); //Get width of dashboard from settings file this.board.BoardSizeX = boardLength; this.board.BoardSizeY = boardWidth; Draw draw = delegate(Interfaces.IBoard board) { }; this.board.Create(); string userInput = string.Empty; while (userInput != null && !userInput.ToLower().Equals("exit")) { this.ioModule.SetPosition(0, boardWidth); ioModule.WriteOutput(phraseProvider.GetMessage("Start") + "\n"); ioModule.WriteOutput(phraseProvider.GetMessage("Rules") + "\n"); ioModule.WriteOutput(phraseProvider.GetMessage("ExitCommand") + "\n"); userInput = ioModule.ReadInput(); switch (userInput) { case "1": if (this.dotFlag) { draw -= this.figures.Dot; } else { draw += this.figures.Dot; } this.dotFlag = !this.dotFlag; break; case "2": if (this.horizontalLineFlag) { draw -= this.figures.HorizontalLine; } else { draw += this.figures.HorizontalLine; } this.horizontalLineFlag = !this.horizontalLineFlag; break; case "3": if (this.verticalLineFlag) { draw -= this.figures.VerticalLine; } else { draw += this.figures.VerticalLine; } this.verticalLineFlag = !this.verticalLineFlag; break; case "4": if (this.sharpLineFlag) { draw -= this.figures.SharpLine; } else { draw += this.figures.SharpLine; } this.sharpLineFlag = !this.sharpLineFlag; break; default: break; } this.ioModule.Clear(); this.board.Create(); draw(this.board); } }