Permalink
Browse files

Demo console app for JAVA and C# - looks nice

  • Loading branch information...
mariuszgromada committed Apr 15, 2016
1 parent 8631464 commit eff10668e3b85557403271e3820a99c967a2145f
Showing with 4,300 additions and 383 deletions.
  1. +6 −1 CURRENT/c-sharp/Janet-Sudoku.csproj
  2. +6 −0 CURRENT/c-sharp/Janet-Sudoku.sln
  3. +6 −0 CURRENT/c-sharp/exe-lib-tests/Janet-Sudoku-Demop-App/App.config
  4. +73 −0 CURRENT/c-sharp/exe-lib-tests/Janet-Sudoku-Demop-App/Janet-Sudoku-Demop-App.csproj
  5. +9 −0 CURRENT/c-sharp/exe-lib-tests/Janet-Sudoku-Demop-App/JanetSudokuDemoApp.cs
  6. +36 −0 CURRENT/c-sharp/exe-lib-tests/Janet-Sudoku-Demop-App/Properties/AssemblyInfo.cs
  7. +1 −1 CURRENT/c-sharp/exe-lib-tests/Run-Tests-API/Run-Tests-API.csproj
  8. +1 −1 CURRENT/c-sharp/exe-lib-tests/Run-Tests-Generator/Run-Tests-Generator.csproj
  9. +1 −1 CURRENT/c-sharp/exe-lib-tests/Run-Tests-Solver/Run-Tests-Solver.csproj
  10. +1 −1 CURRENT/c-sharp/exe-lib-tests/Run-Tests-Store/Run-Tests-Store.csproj
  11. +1 −1 CURRENT/c-sharp/exe-lib-tests/Run-Tests/Run-Tests.csproj
  12. +1 −1 CURRENT/c-sharp/exe-lib-tests/Run-Tutorial/Run-Tutorial.csproj
  13. +84 −6 CURRENT/c-sharp/src/org/mariuszgromada/math/janetsudoku/SudokuStore.cs
  14. +110 −0 CURRENT/c-sharp/src/org/mariuszgromada/math/janetsudoku/demoapp/JanetConsole.cs
  15. +837 −0 CURRENT/c-sharp/src/org/mariuszgromada/math/janetsudoku/demoapp/JanetSudoku.cs
  16. +133 −0 CURRENT/c-sharp/src/org/mariuszgromada/math/janetsudoku/demoapp/Menu.cs
  17. +272 −0 CURRENT/c-sharp/src/org/mariuszgromada/math/janetsudoku/demoapp/MenuData.cs
  18. +4 −2 CURRENT/doc/allclasses-frame.html
  19. +4 −2 CURRENT/doc/allclasses-noframe.html
  20. +23 −2 CURRENT/doc/constant-values.html
  21. +2 −2 CURRENT/doc/deprecated-list.html
  22. +2 −2 CURRENT/doc/help-doc.html
  23. +4 −4 CURRENT/doc/index-files/index-1.html
  24. +16 −4 CURRENT/doc/index-files/index-10.html
  25. +8 −4 CURRENT/doc/index-files/index-11.html
  26. +4 −4 CURRENT/doc/index-files/index-12.html
  27. +6 −4 CURRENT/doc/index-files/index-13.html
  28. +16 −4 CURRENT/doc/index-files/index-14.html
  29. +17 −4 CURRENT/doc/index-files/index-15.html
  30. +16 −4 CURRENT/doc/index-files/index-16.html
  31. +6 −6 CURRENT/doc/index-files/index-17.html
  32. +131 −0 CURRENT/doc/index-files/index-18.html
  33. +4 −4 CURRENT/doc/index-files/index-2.html
  34. +4 −4 CURRENT/doc/index-files/index-3.html
  35. +4 −4 CURRENT/doc/index-files/index-4.html
  36. +8 −4 CURRENT/doc/index-files/index-5.html
  37. +4 −4 CURRENT/doc/index-files/index-6.html
  38. +14 −4 CURRENT/doc/index-files/index-7.html
  39. +4 −4 CURRENT/doc/index-files/index-8.html
  40. +19 −4 CURRENT/doc/index-files/index-9.html
  41. +1 −1 CURRENT/doc/index.html
  42. +2 −2 CURRENT/doc/org/mariuszgromada/math/janetsudoku/BoardCell.html
  43. +2 −2 CURRENT/doc/org/mariuszgromada/math/janetsudoku/ErrorCodes.html
  44. +2 −2 CURRENT/doc/org/mariuszgromada/math/janetsudoku/SudokuBoard.html
  45. +2 −2 CURRENT/doc/org/mariuszgromada/math/janetsudoku/SudokuGenerator.html
  46. +2 −2 CURRENT/doc/org/mariuszgromada/math/janetsudoku/SudokuPuzzles.html
  47. +3 −3 CURRENT/doc/org/mariuszgromada/math/janetsudoku/SudokuSolver.html
  48. +105 −40 CURRENT/doc/org/mariuszgromada/math/janetsudoku/SudokuStore.html
  49. +2 −2 CURRENT/doc/org/mariuszgromada/math/janetsudoku/class-use/BoardCell.html
  50. +2 −2 CURRENT/doc/org/mariuszgromada/math/janetsudoku/class-use/ErrorCodes.html
  51. +2 −2 CURRENT/doc/org/mariuszgromada/math/janetsudoku/class-use/SudokuBoard.html
  52. +2 −2 CURRENT/doc/org/mariuszgromada/math/janetsudoku/class-use/SudokuGenerator.html
  53. +2 −2 CURRENT/doc/org/mariuszgromada/math/janetsudoku/class-use/SudokuPuzzles.html
  54. +2 −2 CURRENT/doc/org/mariuszgromada/math/janetsudoku/class-use/SudokuSolver.html
  55. +2 −2 CURRENT/doc/org/mariuszgromada/math/janetsudoku/class-use/SudokuStore.html
  56. +370 −0 CURRENT/doc/org/mariuszgromada/math/janetsudoku/demoapp/Console.html
  57. +370 −0 CURRENT/doc/org/mariuszgromada/math/janetsudoku/demoapp/JanetConsole.html
  58. +483 −0 CURRENT/doc/org/mariuszgromada/math/janetsudoku/demoapp/JanetSudoku.html
  59. +124 −0 CURRENT/doc/org/mariuszgromada/math/janetsudoku/demoapp/class-use/Console.html
  60. +124 −0 CURRENT/doc/org/mariuszgromada/math/janetsudoku/demoapp/class-use/JanetConsole.html
  61. +124 −0 CURRENT/doc/org/mariuszgromada/math/janetsudoku/demoapp/class-use/JanetSudoku.html
  62. +21 −0 CURRENT/doc/org/mariuszgromada/math/janetsudoku/demoapp/package-frame.html
  63. +151 −0 CURRENT/doc/org/mariuszgromada/math/janetsudoku/demoapp/package-summary.html
  64. +138 −0 CURRENT/doc/org/mariuszgromada/math/janetsudoku/demoapp/package-tree.html
  65. +124 −0 CURRENT/doc/org/mariuszgromada/math/janetsudoku/demoapp/package-use.html
  66. +2 −2 CURRENT/doc/org/mariuszgromada/math/janetsudoku/package-frame.html
  67. +4 −4 CURRENT/doc/org/mariuszgromada/math/janetsudoku/package-summary.html
  68. +4 −4 CURRENT/doc/org/mariuszgromada/math/janetsudoku/package-tree.html
  69. +2 −2 CURRENT/doc/org/mariuszgromada/math/janetsudoku/package-use.html
  70. +2 −2 CURRENT/doc/org/mariuszgromada/math/janetsudoku/regtests/RegTests.html
  71. +2 −2 CURRENT/doc/org/mariuszgromada/math/janetsudoku/regtests/RegTestsApi.html
  72. +2 −2 CURRENT/doc/org/mariuszgromada/math/janetsudoku/regtests/RegTestsGenerator.html
  73. +2 −2 CURRENT/doc/org/mariuszgromada/math/janetsudoku/regtests/RegTestsSolver.html
  74. +2 −2 CURRENT/doc/org/mariuszgromada/math/janetsudoku/regtests/RegTestsStore.html
  75. +2 −2 CURRENT/doc/org/mariuszgromada/math/janetsudoku/regtests/class-use/RegTests.html
  76. +2 −2 CURRENT/doc/org/mariuszgromada/math/janetsudoku/regtests/class-use/RegTestsApi.html
  77. +2 −2 CURRENT/doc/org/mariuszgromada/math/janetsudoku/regtests/class-use/RegTestsGenerator.html
  78. +2 −2 CURRENT/doc/org/mariuszgromada/math/janetsudoku/regtests/class-use/RegTestsSolver.html
  79. +2 −2 CURRENT/doc/org/mariuszgromada/math/janetsudoku/regtests/class-use/RegTestsStore.html
  80. +2 −2 CURRENT/doc/org/mariuszgromada/math/janetsudoku/regtests/package-frame.html
  81. +4 −4 CURRENT/doc/org/mariuszgromada/math/janetsudoku/regtests/package-summary.html
  82. +4 −4 CURRENT/doc/org/mariuszgromada/math/janetsudoku/regtests/package-tree.html
  83. +2 −2 CURRENT/doc/org/mariuszgromada/math/janetsudoku/regtests/package-use.html
  84. +6 −5 CURRENT/doc/org/mariuszgromada/math/janetsudoku/tutorial/Tutorial.html
  85. +2 −2 CURRENT/doc/org/mariuszgromada/math/janetsudoku/tutorial/class-use/Tutorial.html
  86. +2 −2 CURRENT/doc/org/mariuszgromada/math/janetsudoku/tutorial/package-frame.html
  87. +2 −2 CURRENT/doc/org/mariuszgromada/math/janetsudoku/tutorial/package-summary.html
  88. +2 −2 CURRENT/doc/org/mariuszgromada/math/janetsudoku/tutorial/package-tree.html
  89. +2 −2 CURRENT/doc/org/mariuszgromada/math/janetsudoku/tutorial/package-use.html
  90. +3 −2 CURRENT/doc/overview-frame.html
  91. +7 −3 CURRENT/doc/overview-summary.html
  92. +5 −2 CURRENT/doc/overview-tree.html
  93. +1 −0 CURRENT/doc/package-list
  94. +1 −1 CURRENT/java/src/org/mariuszgromada/math/janetsudoku/SudokuStore.java
  95. +4 −5 CURRENT/java/src/org/mariuszgromada/math/janetsudoku/demoapp/{Console.java → JanetConsole.java}
  96. +148 −139 CURRENT/java/src/org/mariuszgromada/math/janetsudoku/demoapp/JanetSudoku.java
  97. +11 −11 CURRENT/java/src/org/mariuszgromada/math/janetsudoku/demoapp/Menu.java
@@ -6,7 +6,7 @@
<ProjectGuid>{C1A7A455-9810-45A2-8C2F-584572AE6A0D}</ProjectGuid>
<OutputType>Library</OutputType>
<NoStandardLibraries>false</NoStandardLibraries>
<AssemblyName>janet-sudoku</AssemblyName>
<AssemblyName>janetsudoku</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
@@ -54,6 +54,10 @@
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="src\org\mariuszgromada\math\janetsudoku\BoardCell.cs" />
<Compile Include="src\org\mariuszgromada\math\janetsudoku\demoapp\JanetConsole.cs" />
<Compile Include="src\org\mariuszgromada\math\janetsudoku\demoapp\JanetSudoku.cs" />
<Compile Include="src\org\mariuszgromada\math\janetsudoku\demoapp\Menu.cs" />
<Compile Include="src\org\mariuszgromada\math\janetsudoku\demoapp\MenuData.cs" />
<Compile Include="src\org\mariuszgromada\math\janetsudoku\ErrorCodes.cs" />
<Compile Include="src\org\mariuszgromada\math\janetsudoku\regtests\RegTests.cs" />
<Compile Include="src\org\mariuszgromada\math\janetsudoku\regtests\RegTestsApi.cs" />
@@ -73,6 +77,7 @@
<ItemGroup>
<None Include="mariuszgromada.org.pfx" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSHARP.Targets" />
<ProjectExtensions>
<VisualStudio AllowExistingFolder="true" />
@@ -17,6 +17,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Run-Tests-Generator", "exe-
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Run-Tests-Store", "exe-lib-tests\Run-Tests-Store\Run-Tests-Store.csproj", "{A269C8E3-9CFB-41F7-B2D7-09FA3164F384}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Janet-Sudoku-Demop-App", "exe-lib-tests\Janet-Sudoku-Demop-App\Janet-Sudoku-Demop-App.csproj", "{F9FC5225-D42C-4F62-BA4C-BC2B38E9785F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -51,6 +53,10 @@ Global
{A269C8E3-9CFB-41F7-B2D7-09FA3164F384}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A269C8E3-9CFB-41F7-B2D7-09FA3164F384}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A269C8E3-9CFB-41F7-B2D7-09FA3164F384}.Release|Any CPU.Build.0 = Release|Any CPU
{F9FC5225-D42C-4F62-BA4C-BC2B38E9785F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F9FC5225-D42C-4F62-BA4C-BC2B38E9785F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F9FC5225-D42C-4F62-BA4C-BC2B38E9785F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F9FC5225-D42C-4F62-BA4C-BC2B38E9785F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
</startup>
</configuration>
@@ -0,0 +1,73 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{F9FC5225-D42C-4F62-BA4C-BC2B38E9785F}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>janetsudoku.demoapp</RootNamespace>
<AssemblyName>janetsudoku-demo</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>..\..\..\..\..\..\pfx-keys\mariuszgromada.org.pfx</AssemblyOriginatorKeyFile>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="JanetSudokuDemoApp.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="mariuszgromada.org.pfx" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Janet-Sudoku.csproj">
<Project>{c1a7a455-9810-45a2-8c2f-584572ae6a0d}</Project>
<Name>Janet-Sudoku</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
@@ -0,0 +1,9 @@
using org.mariuszgromada.math.janetsudoku.demoapp;
namespace janetsudoku.demoapp {
class JanetSudokuDemoApp {
static void Main(string[] args) {
JanetSudoku.Start();
}
}
}
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Janet Sudoku - Demo App")]
[assembly: AssemblyDescription("Janet Sudoku - Demo Application")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("MariuszGromada.org")]
[assembly: AssemblyProduct("Janet Sudoku")]
[assembly: AssemblyCopyright("Copyright © 2016 Mariusz Gromada")]
[assembly: AssemblyTrademark("Janet Sudoku")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("f9fc5225-d42c-4f62-ba4c-bc2b38e9785f")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
@@ -8,7 +8,7 @@
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>janetsudoku.runtests</RootNamespace>
<AssemblyName>janet-sudoku-run-tests-api</AssemblyName>
<AssemblyName>janetsudoku-runtests-api</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
@@ -8,7 +8,7 @@
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>janetsudoku.runtests</RootNamespace>
<AssemblyName>janet-sudoku-run-tests-generator</AssemblyName>
<AssemblyName>janetsudoku-runtests-generator</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
@@ -8,7 +8,7 @@
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>janetsudoku.runtests</RootNamespace>
<AssemblyName>janet-sudoku-run-tests-solver</AssemblyName>
<AssemblyName>janetsudoku-runtests-solver</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
@@ -8,7 +8,7 @@
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>janetsudoku.runtests</RootNamespace>
<AssemblyName>janet-sudoku-run-tests-store</AssemblyName>
<AssemblyName>janetsudoku-runtests-store</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
@@ -8,7 +8,7 @@
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>janetsudoku.runtests</RootNamespace>
<AssemblyName>janet-sudoku-run-tests-all</AssemblyName>
<AssemblyName>janetsudoku-runtests-all</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
@@ -8,7 +8,7 @@
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>janetsudoku.runtests</RootNamespace>
<AssemblyName>janet-sudoku-run-tutorial</AssemblyName>
<AssemblyName>janetsudoku-run-tutorial</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
@@ -383,6 +383,74 @@ class Runner {
}
return sudokuBoard;
}
/**
* Loads Sudoku board from one string line ('0' and' '.' treated as empty cell).
* Any other char than '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.'
* is being filtered out.
*
* @param boardDefinition Board definition in one string line containing
* row after row.
* @return Loaded board if data is sufficient to fill 81 cells
* (including empty cells), otherwise null.
*/
public static int[,] loadBoardFromStringLine(String boardDefinition) {
int lastInex = BOARD_SIZE - 1;
if (boardDefinition == null) return null;
if (boardDefinition.Length < SudokuBoard.BOARD_CELLS_NUMBER) return null;
int[,] board = boardCopy(SudokuPuzzles.PUZZLE_EMPTY);
int cellNum = 0;
int i = 0;
int j = -1;
char[] line = boardDefinition.ToCharArray();
for (int k = 0; k < line.Length; k++) {
char c = line[k];
int d = -1;
if (c == '1') d = 1;
else if (c == '2') d = 2;
else if (c == '3') d = 3;
else if (c == '4') d = 4;
else if (c == '5') d = 5;
else if (c == '6') d = 6;
else if (c == '7') d = 7;
else if (c == '8') d = 8;
else if (c == '9') d = 9;
else if (c == '0') d = 0;
else if (c == '.') d = 0;
if ((d >= 0) && (cellNum < SudokuBoard.BOARD_CELLS_NUMBER)) {
j++;
cellNum++;
board[i, j] = d;
if (j == lastInex) {
i++;
j = -1;
}
}
}
if (cellNum == SudokuBoard.BOARD_CELLS_NUMBER) return board;
else return null;
}
/**
* Loads Sudoku board from variadic list of strings (each string as a
* one row)
*
* Format:
* Any character different than '1-9' and '.' is being removed.
* Any line starting with '#' is being removed.
* Any empty line is being removed.
* Any final line having less than 9 characters is being removed.
*
* If number of final lines is less then 9 then null is returned.
*
* Finally 9 starting characters for first 9 lines is the
* loaded board definition.
*
* @param boardDefinition Board definition (variadic list of strings).
* @return Array representing loaded Sudoku board,
* null - if problem occurred while loading.
*/
public static int[,] loadBoardFromStrings(params String[] boardDefinition) {
return loadBoard(boardDefinition);
}
/**
* Saves board to the text file.
*
@@ -1375,29 +1443,39 @@ class Runner {
*/
private static String convBoardToString(int[,] sudokuBoard, String headComment, String tailComment) {
String boardStr = "";
String oneLineDefDot = "";
String oneLineDefZero = "";
if (headComment != null)
if (headComment.Length > 0)
boardStr = boardStr + "# " + headComment + NEW_LINE_SEPARATOR + NEW_LINE_SEPARATOR;
boardStr = boardStr + "# " + headComment + NEW_LINE_SEPARATOR + NEW_LINE_SEPARATOR;
if (sudokuBoard == null) return "NULL sudoku board.";
boardStr = boardStr + "+-------+-------+-------+" + NEW_LINE_SEPARATOR;
for (int i = 0; i < SudokuBoard.BOARD_SIZE; i ++) {
for (int i = 0; i < SudokuBoard.BOARD_SIZE; i++) {
if ((i > 0) && (i < SudokuBoard.BOARD_SIZE) && (i % SudokuBoard.BOARD_SUB_SQURE_SIZE == 0))
boardStr = boardStr + "+-------+-------+-------+" + NEW_LINE_SEPARATOR ;
boardStr = boardStr + "+-------+-------+-------+" + NEW_LINE_SEPARATOR;
boardStr = boardStr + "| ";
for (int j = 0; j < SudokuBoard.BOARD_SIZE; j++) {
if ((j > 0) && (j < SudokuBoard.BOARD_SIZE) && (j % SudokuBoard.BOARD_SUB_SQURE_SIZE == 0))
boardStr = boardStr + "| ";
if (sudokuBoard[i, j] != BoardCell.EMPTY)
if (sudokuBoard[i, j] != BoardCell.EMPTY) {
boardStr = boardStr + sudokuBoard[i, j] + " ";
else
oneLineDefDot = oneLineDefDot + sudokuBoard[i, j];
oneLineDefZero = oneLineDefZero + sudokuBoard[i, j];
} else {
boardStr = boardStr + ". ";
oneLineDefDot = oneLineDefDot + '.';
oneLineDefZero = oneLineDefZero + '0';
}
}
boardStr = boardStr + "|" + NEW_LINE_SEPARATOR;
}
boardStr = boardStr + "+-------+-------+-------+" + NEW_LINE_SEPARATOR + NEW_LINE_SEPARATOR;
boardStr = boardStr + "# One line definition:" + NEW_LINE_SEPARATOR;
boardStr = boardStr + "# " + oneLineDefDot + NEW_LINE_SEPARATOR;
boardStr = boardStr + "# " + oneLineDefZero + NEW_LINE_SEPARATOR + NEW_LINE_SEPARATOR;
if (tailComment != null)
if (tailComment.Length > 0)
boardStr = boardStr + "# " + tailComment;
boardStr = NEW_LINE_SEPARATOR + NEW_LINE_SEPARATOR + boardStr + "# " + tailComment;
return boardStr;
}
/**
Oops, something went wrong.

0 comments on commit eff1066

Please sign in to comment.