Commit 06a2f5ca by adbaga

Adding validation input: Doesn't accept non int and set maximum size of the board

parent 2727274a
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="a128ca0c-796d-4da2-8db0-062a4837d105" name="Default Changelist" comment="" /> <list default="true" id="a128ca0c-796d-4da2-8db0-062a4837d105" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/.idea.IDoMinesweeper/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/.idea.IDoMinesweeper/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/IDoMinesweeper/Program.cs" beforeDir="false" afterPath="$PROJECT_DIR$/IDoMinesweeper/Program.cs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/IDoMinesweeper/bin/Debug/netcoreapp3.0/IDoMinesweeper.dll" beforeDir="false" afterPath="$PROJECT_DIR$/IDoMinesweeper/bin/Debug/netcoreapp3.0/IDoMinesweeper.dll" afterDir="false" />
<change beforePath="$PROJECT_DIR$/IDoMinesweeper/bin/Debug/netcoreapp3.0/IDoMinesweeper.pdb" beforeDir="false" afterPath="$PROJECT_DIR$/IDoMinesweeper/bin/Debug/netcoreapp3.0/IDoMinesweeper.pdb" afterDir="false" />
<change beforePath="$PROJECT_DIR$/IDoMinesweeper/obj/Debug/netcoreapp3.0/IDoMinesweeper.csprojAssemblyReference.cache" beforeDir="false" afterPath="$PROJECT_DIR$/IDoMinesweeper/obj/Debug/netcoreapp3.0/IDoMinesweeper.csprojAssemblyReference.cache" afterDir="false" />
<change beforePath="$PROJECT_DIR$/IDoMinesweeper/obj/Debug/netcoreapp3.0/IDoMinesweeper.dll" beforeDir="false" afterPath="$PROJECT_DIR$/IDoMinesweeper/obj/Debug/netcoreapp3.0/IDoMinesweeper.dll" afterDir="false" />
<change beforePath="$PROJECT_DIR$/IDoMinesweeper/obj/Debug/netcoreapp3.0/IDoMinesweeper.pdb" beforeDir="false" afterPath="$PROJECT_DIR$/IDoMinesweeper/obj/Debug/netcoreapp3.0/IDoMinesweeper.pdb" afterDir="false" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" /> <option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
...@@ -32,8 +40,8 @@ ...@@ -32,8 +40,8 @@
<option value="$PROJECT_DIR$/Game/CellState.cs" /> <option value="$PROJECT_DIR$/Game/CellState.cs" />
<option value="$PROJECT_DIR$/ConsoleUserInt/GameUI.cs" /> <option value="$PROJECT_DIR$/ConsoleUserInt/GameUI.cs" />
<option value="$PROJECT_DIR$/Game/Engine.cs" /> <option value="$PROJECT_DIR$/Game/Engine.cs" />
<option value="$PROJECT_DIR$/IDoMinesweeper/Program.cs" />
<option value="$PROJECT_DIR$/MenuSystem/Menu.cs" /> <option value="$PROJECT_DIR$/MenuSystem/Menu.cs" />
<option value="$PROJECT_DIR$/IDoMinesweeper/Program.cs" />
</list> </list>
</option> </option>
</component> </component>
...@@ -96,8 +104,16 @@ ...@@ -96,8 +104,16 @@
<workItem from="1570541467008" duration="1357000" /> <workItem from="1570541467008" duration="1357000" />
<workItem from="1570543449378" duration="28421000" /> <workItem from="1570543449378" duration="28421000" />
<workItem from="1570828559519" duration="1080000" /> <workItem from="1570828559519" duration="1080000" />
<workItem from="1570969640551" duration="272000" /> <workItem from="1570969640551" duration="1737000" />
</task>
<task id="LOCAL-00001" summary="yes">
<created>1570973690674</created>
<option name="number" value="00001" />
<option name="presentableId" value="LOCAL-00001" />
<option name="project" value="LOCAL" />
<updated>1570973690675</updated>
</task> </task>
<option name="localTasksCounter" value="2" />
<servers /> <servers />
</component> </component>
<component name="TypeScriptGeneratedFilesManager"> <component name="TypeScriptGeneratedFilesManager">
...@@ -118,6 +134,8 @@ ...@@ -118,6 +134,8 @@
</component> </component>
<component name="VcsManagerConfiguration"> <component name="VcsManagerConfiguration">
<option name="LOCAL_CHANGES_DETAILS_PREVIEW_SHOWN" value="true" /> <option name="LOCAL_CHANGES_DETAILS_PREVIEW_SHOWN" value="true" />
<MESSAGE value="yes" />
<option name="LAST_COMMIT_MESSAGE" value="yes" />
</component> </component>
<component name="XDebuggerManager"> <component name="XDebuggerManager">
<breakpoint-manager> <breakpoint-manager>
......
...@@ -83,25 +83,61 @@ namespace IDoMinesweeper ...@@ -83,25 +83,61 @@ namespace IDoMinesweeper
WriteLine("Board height (Min. 8): "); WriteLine("Board height (Min. 8): ");
WriteLine(">"); WriteLine(">");
var checkHeight = ReadLine();
int height = 0;
if (!int.TryParse(checkHeight, out height))
{
Console.WriteLine("Not an integer");
}
else
{
height = Convert.ToInt32(checkHeight);
}
int height = Convert.ToInt32(ReadLine());
WriteLine("Board width (Min. 8): "); WriteLine("Board width (Min. 8): ");
WriteLine(">"); WriteLine(">");
var width = Convert.ToInt32(ReadLine());
var checkWidth = ReadLine();
int width = 0;
if (!int.TryParse(checkHeight, out height))
{
Console.WriteLine("Not an integer");
}
else
{
width = Convert.ToInt32(checkWidth);
}
//var width = Convert.ToInt32(ReadLine());
var doIt = false; var doIt = false;
do do
{ {
if (height < 8 || width < 8) if (height < 8 || width < 8)
{ {
Console.WriteLine("Too small"); Console.WriteLine("Too small. Minimal is 8x8");
return ""; return "";
break; break;
} }
else if(height > 30 || width > 30)
{
Console.WriteLine("Too big. Maximum size is 30x30");
return "";
break;
}
else else
{ {
doIt = true; doIt = true;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment