private IDataGet GetDataGet(string select) { IDataGet dataGet = null; switch (select) { case "1": { dataGet = new Writer(); break; } case "2": { Console.WriteLine("Enter the path of the data file For example: Data.txt"); dataGet = new Txtriter(Console.ReadLine()); break; } default: { Console.WriteLine("not in correct format."); Console.ReadKey(); Environment.Exit(0); break; } } return(dataGet); }
private void MakeTurn(Cell fromCell, Cell toCell, Figure figure) { IDataGet proxy = OpenProxy(); try { if (!proxy.IsAvailable()) { throw new NetworkException("Server not available."); } } catch (EndpointNotFoundException exception) { throw new NetworkException("Server not available: EndpointNotFoundException", exception); } proxy.GetData(new Data() { CelHorPosition = fromCell.HorPosition, CellVertPosition = fromCell.VertPosition }, new Data() { CelHorPosition = toCell.HorPosition, CellVertPosition = toCell.VertPosition, CellFigureName = figure != null ? figure.GetType().Name : null }); }
public void Worker() { bool isBuilt_By = false; Console.WriteLine("Select method load data: 1 - console enterd, 2 - txt"); dataGet = GetDataGet(Console.ReadLine()); string widthAndHeightWall = dataGet.GetWidthAndHeightWall(); List <int[]> wall = dataGet.GetWall(widthAndHeightWall); List <Brick> bricks = dataGet.GetBricks(); dataGet.WriteData(widthAndHeightWall, wall, bricks); bricks.Sort((c1, c2) => c2.Width.CompareTo(c1.Width)); for (int i = 0; i < bricks.Count; i++) { if (i != 0) { var buf = bricks[0]; bricks[0] = bricks[i]; bricks[i] = buf; } UsedCountToZero(bricks); List <int[]> newWall = GoBuilder(Convert.ToInt32(widthAndHeightWall.Split(' ')[0]), Convert.ToInt32(widthAndHeightWall.Split(' ')[1]), wall, bricks); if (newWall.FirstOrDefault(w => w.FirstOrDefault(arr => arr == 1) == 1) == null) { Console.WriteLine("YES"); isBuilt_By = true; return; } } if (!isBuilt_By) { Console.WriteLine("NO"); } }