static void Main(string[] args) { Console.WriteLine("Size: "); String input = Console.ReadLine(); int size = Int32.Parse(input); Puzzle puzzle = new Puzzle(size); PuzzlePrinter printer = new PuzzlePrinter(puzzle); printer.PrintPuzzle(); while (true) { Console.WriteLine("Move Target: "); input = Console.ReadLine(); if (input != null) { if (input.Equals("quit")) { break; } Tile targetTile = printer[input]; if (targetTile != null) { Puzzle.MoveProperties moveProperties = puzzle.MakeMove(targetTile.CurrentPosition); if (moveProperties.Direction != Puzzle.MoveDirection.None) { printer.PrintPuzzle(); } } } } }
public static IServiceCollection AddApplicationServices(this IServiceCollection serviceCollection) { serviceCollection.AddTransient <PuzzleGenerator <SudokuPuzzle>, SudokuGenerator>(); serviceCollection.AddTransient <PuzzlePrinter <SudokuPuzzle>, SudokuPrinter>(); serviceCollection.AddTransient <IRestServiceConnector, RestServiceConnector>(serviceProvider => new RestServiceConnector(Client)); serviceCollection.AddTransient <IPuzzleStorageService, PuzzleStorageService>(); serviceCollection.AddTransient <IPuzzleService <SudokuPuzzle>, SudokuPuzzleService>(serviceProvider => { PuzzleGenerator <SudokuPuzzle> puzzleGenerator = serviceProvider.GetService <PuzzleGenerator <SudokuPuzzle> >(); PuzzlePrinter <SudokuPuzzle> puzzlePrinter = serviceProvider.GetService <PuzzlePrinter <SudokuPuzzle> >(); return(new SudokuPuzzleService(puzzleGenerator, puzzlePrinter)); }); return(serviceCollection); }
public SudokuPuzzleService(PuzzleGenerator <SudokuPuzzle> puzzleGenerator, PuzzlePrinter <SudokuPuzzle> sudokuPrinter) { _sudokuGenerator = puzzleGenerator; _sudokuPrinter = sudokuPrinter; }