Commit fe48d7ed by adbaga

Initial commit Minesweeper

parents
Showing with 2129 additions and 0 deletions
File added
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ContentModelStore">
<e p="$USER_HOME$/Library/Caches/Rider2019.2/extResources" t="IncludeRecursive" />
<e p="$USER_HOME$/Library/Caches/Rider2019.2/resharper-host/local/Transient/ReSharperHost/v192/SolutionCaches/_IDoMinesweeper.1316311717.00" t="ExcludeRecursive" />
<e p="$APPLICATION_CONFIG_DIR$/scratches" t="IncludeRecursive" />
<e p="$PROJECT_DIR$" t="IncludeFlat">
<e p="ConsoleUserInt" t="IncludeRecursive">
<e p="bin" t="ExcludeRecursive" />
<e p="ConsoleUserInt.csproj" t="IncludeRecursive" />
<e p="GameUI.cs" t="Include" />
<e p="obj" t="ExcludeRecursive">
<e p="Debug" t="Include">
<e p="netcoreapp3.0" t="Include">
<e p="ConsoleUserInt.AssemblyInfo.cs" t="Include" />
</e>
</e>
</e>
</e>
<e p="Game" t="IncludeRecursive">
<e p="bin" t="ExcludeRecursive" />
<e p="CellState.cs" t="Include" />
<e p="Engine.cs" t="Include" />
<e p="Game.csproj" t="IncludeRecursive" />
<e p="obj" t="ExcludeRecursive">
<e p="Debug" t="Include">
<e p="netcoreapp3.0" t="Include">
<e p="Game.AssemblyInfo.cs" t="Include" />
</e>
</e>
</e>
</e>
<e p="IDoMinesweeper" t="IncludeRecursive">
<e p="bin" t="ExcludeRecursive" />
<e p="IDoMinesweeper.csproj" t="IncludeRecursive" />
<e p="obj" t="ExcludeRecursive">
<e p="Debug" t="Include">
<e p="netcoreapp3.0" t="Include">
<e p="IDoMinesweeper.AssemblyInfo.cs" t="Include" />
</e>
</e>
</e>
<e p="Program.cs" t="Include" />
</e>
<e p="IDoMinesweeper.sln" t="IncludeFlat" />
<e p="MenuSystem" t="IncludeRecursive">
<e p="bin" t="ExcludeRecursive" />
<e p="Menu.cs" t="Include" />
<e p="MenuItem.cs" t="Include" />
<e p="MenuSystem.csproj" t="IncludeRecursive" />
<e p="obj" t="ExcludeRecursive">
<e p="Debug" t="Include">
<e p="netcoreapp3.0" t="Include">
<e p="MenuSystem.AssemblyInfo.cs" t="Include" />
</e>
</e>
</e>
</e>
<e p="packages" t="ExcludeRecursive" />
</e>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ContentModelUserStore">
<attachedFolders />
<explicitIncludes />
<explicitExcludes />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/.idea.IDoMinesweeper/riderModule.iml" filepath="$PROJECT_DIR$/.idea/.idea.IDoMinesweeper/riderModule.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RiderProjectSettingsUpdater">
<option name="vcsConfiguration" value="1" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="a128ca0c-796d-4da2-8db0-062a4837d105" name="Default Changelist" comment="" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="HighlightingSettingsPerFile">
<setting file="file://$PROJECT_DIR$/Game/CellState.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/ConsoleUserInt/GameUI.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/MenuSystem/MenuItem.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/MenuSystem/Menu.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/Game/Engine.cs" root0="FORCE_HIGHLIGHTING" />
<setting file="file://$PROJECT_DIR$/IDoMinesweeper/Program.cs" root0="FORCE_HIGHLIGHTING" />
</component>
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/MenuSystem/Class1.cs" />
<option value="$PROJECT_DIR$/MenuSystem/MenuItem.cs" />
<option value="$PROJECT_DIR$/Game/Class1.cs" />
<option value="$PROJECT_DIR$/ConsoleUI/Program.cs" />
<option value="$PROJECT_DIR$/ConsoleUI/Class1.cs" />
<option value="$PROJECT_DIR$/GameUI/Class1.cs" />
<option value="$PROJECT_DIR$/ConsoleUserInt/Class1.cs" />
<option value="$PROJECT_DIR$/Game/CellState.cs" />
<option value="$PROJECT_DIR$/ConsoleUserInt/GameUI.cs" />
<option value="$PROJECT_DIR$/Game/Engine.cs" />
<option value="$PROJECT_DIR$/IDoMinesweeper/Program.cs" />
<option value="$PROJECT_DIR$/MenuSystem/Menu.cs" />
</list>
</option>
</component>
<component name="ProjectId" id="1Rv3u8pClg7mNGMw8dCZYVDi1k9" />
<component name="PropertiesComponent">
<property name="Rider.DefaultBreakpoints.AreToggled" value="true" />
<property name="Rider.ProjectViewActivator.IsNotFirstRun" value="true" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="node.js.detected.package.eslint" value="true" />
<property name="node.js.detected.package.tslint" value="true" />
<property name="node.js.path.for.package.eslint" value="project" />
<property name="node.js.path.for.package.tslint" value="project" />
<property name="node.js.selected.package.eslint" value="(autodetect)" />
<property name="node.js.selected.package.tslint" value="(autodetect)" />
</component>
<component name="RunDashboard">
<option name="ruleStates">
<list>
<RuleState>
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
</RuleState>
<RuleState>
<option name="name" value="StatusDashboardGroupingRule" />
</RuleState>
</list>
</option>
</component>
<component name="RunManager">
<configuration name="Default" type="DotNetProject" factoryName=".NET Project">
<option name="EXE_PATH" value="$PROJECT_DIR$/IDoMinesweeper/bin/Debug/netcoreapp3.0/IDoMinesweeper.dll" />
<option name="PROGRAM_PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/IDoMinesweeper/bin/Debug/netcoreapp3.0" />
<option name="PASS_PARENT_ENVS" value="1" />
<option name="USE_EXTERNAL_CONSOLE" value="0" />
<option name="USE_MONO" value="0" />
<option name="RUNTIME_ARGUMENTS" value="" />
<option name="PROJECT_PATH" value="$PROJECT_DIR$/IDoMinesweeper/IDoMinesweeper.csproj" />
<option name="PROJECT_EXE_PATH_TRACKING" value="1" />
<option name="PROJECT_ARGUMENTS_TRACKING" value="1" />
<option name="PROJECT_WORKING_DIRECTORY_TRACKING" value="1" />
<option name="PROJECT_KIND" value="DotNetCore" />
<option name="PROJECT_TFM" value=".NETCoreApp,Version=v3.0" />
<method v="2">
<option name="Build" enabled="true" />
</method>
</configuration>
</component>
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="a128ca0c-796d-4da2-8db0-062a4837d105" name="Default Changelist" comment="" />
<created>1570533962048</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1570533962048</updated>
<workItem from="1570533964044" duration="2786000" />
<workItem from="1570541467008" duration="1357000" />
<workItem from="1570543449378" duration="28421000" />
<workItem from="1570828559519" duration="1080000" />
</task>
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="1" />
</component>
<component name="UnityProjectConfiguration" hasMinimizedUI="false" />
<component name="UnityUnitTestConfiguration" currentTestLauncher="NUnit" />
<component name="VcsManagerConfiguration">
<option name="LOCAL_CHANGES_DETAILS_PREVIEW_SHOWN" value="true" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager>
<breakpoints>
<breakpoint enabled="true" suspend="NONE" type="DotNet Exception Breakpoints">
<properties exception="System.Threading.ThreadAbortException" displayValue="System.Threading.ThreadAbortException" />
<option name="timeStamp" value="1" />
</breakpoint>
</breakpoints>
</breakpoint-manager>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<module type="RIDER_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$/../.." />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
\ No newline at end of file
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Game\Game.csproj" />
</ItemGroup>
</Project>
using System;
using System.ComponentModel;
using Game;
namespace ConsoleUserInt
{
namespace ConsoleUI
{
public static class GameUI
{
private static readonly string _verticalSeparator = "|";
private static readonly string _horizontalSeparator = "-";
private static readonly string _centerSeparator = "+";
public static void PrintBoard(Engine.BoardDim game)
{
var board = game.GetBoard();
for (int yIndex = 0; yIndex < game.BoardHeight; yIndex++)
{
var line = "";
for (int xIndex = 0; xIndex < game.BoardWidth; xIndex++)
{
line = line + " " + GetSingleState(board[yIndex, xIndex]) + " ";
if (xIndex < game.BoardWidth - 1)
{
line = line + _verticalSeparator;
}
}
Console.WriteLine(line);
if (yIndex < game.BoardHeight - 1)
{
line = "";
for (int xIndex = 0; xIndex < game.BoardWidth; xIndex++)
{
line = line + _horizontalSeparator+ _horizontalSeparator+ _horizontalSeparator;
if (xIndex < game.BoardWidth - 1)
{
line = line +_centerSeparator;
}
}
Console.WriteLine(line);
}
}
}
public static string GetSingleState(CellState state)
{
switch (state)
{
case CellState.Empty:
return " ";
case CellState.Mine:
return "§";
case CellState.Flag:
return "±";
case CellState.Hidden:
return "-";
default:
throw new InvalidEnumArgumentException("Unknown enum option!");
}
}
//so, randomizer should generate an array in that range where the mines are stored. If they insert y/x where mine is stored, game ends
}
}
}
\ No newline at end of file
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v3.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v3.0": {
"ConsoleUserInt/1.0.0": {
"dependencies": {
"Game": "1.0.0"
},
"runtime": {
"ConsoleUserInt.dll": {}
}
},
"Game/1.0.0": {
"runtime": {
"Game.dll": {}
}
}
}
},
"libraries": {
"ConsoleUserInt/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"Game/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}
\ No newline at end of file
{
"version": 1,
"dgSpecHash": "e6sxTcOEqdvydqe8gxBimHjIcO6P6vO8mynky3eFndFohoSgNR1/2og4otA8sw1iTdKJaLEqoW+FqeGwLQeh0Q==",
"success": true
}
\ No newline at end of file
{
"format": 1,
"restore": {
"/Users/kalevkim/secureprogramming/IDoMinesweeper/ConsoleUserInt/ConsoleUserInt.csproj": {}
},
"projects": {
"/Users/kalevkim/secureprogramming/IDoMinesweeper/ConsoleUserInt/ConsoleUserInt.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "/Users/kalevkim/secureprogramming/IDoMinesweeper/ConsoleUserInt/ConsoleUserInt.csproj",
"projectName": "ConsoleUserInt",
"projectPath": "/Users/kalevkim/secureprogramming/IDoMinesweeper/ConsoleUserInt/ConsoleUserInt.csproj",
"packagesPath": "/Users/kalevkim/.nuget/packages/",
"outputPath": "/Users/kalevkim/secureprogramming/IDoMinesweeper/ConsoleUserInt/obj/",
"projectStyle": "PackageReference",
"fallbackFolders": [
"/usr/local/share/dotnet/sdk/NuGetFallbackFolder"
],
"configFilePaths": [
"/Users/kalevkim/.config/NuGet/NuGet.Config"
],
"originalTargetFrameworks": [
"netcoreapp3.0"
],
"sources": {
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"netcoreapp3.0": {
"projectReferences": {
"/Users/kalevkim/secureprogramming/IDoMinesweeper/Game/Game.csproj": {
"projectPath": "/Users/kalevkim/secureprogramming/IDoMinesweeper/Game/Game.csproj"
}
}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"netcoreapp3.0": {
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48"
],
"assetTargetFallback": true,
"warn": true
}
}
},
"/Users/kalevkim/secureprogramming/IDoMinesweeper/Game/Game.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "/Users/kalevkim/secureprogramming/IDoMinesweeper/Game/Game.csproj",
"projectName": "Game",
"projectPath": "/Users/kalevkim/secureprogramming/IDoMinesweeper/Game/Game.csproj",
"packagesPath": "/Users/kalevkim/.nuget/packages/",
"outputPath": "/Users/kalevkim/secureprogramming/IDoMinesweeper/Game/obj/",
"projectStyle": "PackageReference",
"fallbackFolders": [
"/usr/local/share/dotnet/sdk/NuGetFallbackFolder"
],
"configFilePaths": [
"/Users/kalevkim/.config/NuGet/NuGet.Config"
],
"originalTargetFrameworks": [
"netcoreapp3.0"
],
"sources": {
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"netcoreapp3.0": {
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"netcoreapp3.0": {
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48"
],
"assetTargetFallback": true,
"warn": true
}
}
}
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">/Users/kalevkim/.nuget/packages/</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">/Users/kalevkim/.nuget/packages/;/usr/local/share/dotnet/sdk/NuGetFallbackFolder</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">5.2.0</NuGetToolVersion>
</PropertyGroup>
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
</Project>
\ No newline at end of file
//------------------------------------------------------------------------------
// <auto-generated>
// Generated by the MSBuild WriteCodeFragment class.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("ConsoleUserInt")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("ConsoleUserInt")]
[assembly: System.Reflection.AssemblyTitleAttribute("ConsoleUserInt")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
/Users/kalevkim/secureprogramming/IDoMinesweeper/ConsoleUserInt/bin/Debug/netcoreapp3.0/ConsoleUserInt.deps.json
/Users/kalevkim/secureprogramming/IDoMinesweeper/ConsoleUserInt/bin/Debug/netcoreapp3.0/ConsoleUserInt.dll
/Users/kalevkim/secureprogramming/IDoMinesweeper/ConsoleUserInt/bin/Debug/netcoreapp3.0/ConsoleUserInt.pdb
/Users/kalevkim/secureprogramming/IDoMinesweeper/ConsoleUserInt/bin/Debug/netcoreapp3.0/Game.dll
/Users/kalevkim/secureprogramming/IDoMinesweeper/ConsoleUserInt/bin/Debug/netcoreapp3.0/Game.pdb
/Users/kalevkim/secureprogramming/IDoMinesweeper/ConsoleUserInt/obj/Debug/netcoreapp3.0/ConsoleUserInt.csprojAssemblyReference.cache
/Users/kalevkim/secureprogramming/IDoMinesweeper/ConsoleUserInt/obj/Debug/netcoreapp3.0/ConsoleUserInt.AssemblyInfoInputs.cache
/Users/kalevkim/secureprogramming/IDoMinesweeper/ConsoleUserInt/obj/Debug/netcoreapp3.0/ConsoleUserInt.AssemblyInfo.cs
/Users/kalevkim/secureprogramming/IDoMinesweeper/ConsoleUserInt/obj/Debug/netcoreapp3.0/ConsoleUserInt.csproj.CopyComplete
/Users/kalevkim/secureprogramming/IDoMinesweeper/ConsoleUserInt/obj/Debug/netcoreapp3.0/ConsoleUserInt.dll
/Users/kalevkim/secureprogramming/IDoMinesweeper/ConsoleUserInt/obj/Debug/netcoreapp3.0/ConsoleUserInt.pdb
{
"version": 3,
"targets": {
".NETCoreApp,Version=v3.0": {
"Game/1.0.0": {
"type": "project",
"framework": ".NETCoreApp,Version=v3.0",
"compile": {
"bin/placeholder/Game.dll": {}
},
"runtime": {
"bin/placeholder/Game.dll": {}
}
}
}
},
"libraries": {
"Game/1.0.0": {
"type": "project",
"path": "../Game/Game.csproj",
"msbuildProject": "../Game/Game.csproj"
}
},
"projectFileDependencyGroups": {
".NETCoreApp,Version=v3.0": [
"Game >= 1.0.0"
]
},
"packageFolders": {
"/Users/kalevkim/.nuget/packages/": {},
"/usr/local/share/dotnet/sdk/NuGetFallbackFolder": {}
},
"project": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "/Users/kalevkim/secureprogramming/IDoMinesweeper/ConsoleUserInt/ConsoleUserInt.csproj",
"projectName": "ConsoleUserInt",
"projectPath": "/Users/kalevkim/secureprogramming/IDoMinesweeper/ConsoleUserInt/ConsoleUserInt.csproj",
"packagesPath": "/Users/kalevkim/.nuget/packages/",
"outputPath": "/Users/kalevkim/secureprogramming/IDoMinesweeper/ConsoleUserInt/obj/",
"projectStyle": "PackageReference",
"fallbackFolders": [
"/usr/local/share/dotnet/sdk/NuGetFallbackFolder"
],
"configFilePaths": [
"/Users/kalevkim/.config/NuGet/NuGet.Config"
],
"originalTargetFrameworks": [
"netcoreapp3.0"
],
"sources": {
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"netcoreapp3.0": {
"projectReferences": {
"/Users/kalevkim/secureprogramming/IDoMinesweeper/Game/Game.csproj": {
"projectPath": "/Users/kalevkim/secureprogramming/IDoMinesweeper/Game/Game.csproj"
}
}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"netcoreapp3.0": {
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48"
],
"assetTargetFallback": true,
"warn": true
}
}
}
}
\ No newline at end of file
{
"version": "1.0.0",
"restore": {
"projectUniqueName": "/Users/kalevkim/secureprogramming/IDoMinesweeper/ConsoleUserInt/ConsoleUserInt.csproj",
"projectName": "ConsoleUserInt",
"projectPath": "/Users/kalevkim/secureprogramming/IDoMinesweeper/ConsoleUserInt/ConsoleUserInt.csproj",
"outputPath": "/Users/kalevkim/secureprogramming/IDoMinesweeper/ConsoleUserInt/obj/",
"projectStyle": "PackageReference",
"fallbackFolders": [
"/usr/local/share/dotnet/sdk/NuGetFallbackFolder"
],
"originalTargetFrameworks": [
"netcoreapp3.0"
],
"sources": {
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"netcoreapp3.0": {
"projectReferences": {
"/Users/kalevkim/secureprogramming/IDoMinesweeper/Game/Game.csproj": {
"projectPath": "/Users/kalevkim/secureprogramming/IDoMinesweeper/Game/Game.csproj"
}
}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"netcoreapp3.0": {
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48"
],
"assetTargetFallback": true,
"warn": true
}
}
}
\ No newline at end of file
File added
namespace Game
{
public enum CellState
{
Empty,
Mine,
Flag,
Hidden,
}
}
\ No newline at end of file
using System;
using Game;
namespace Engine
{
public class BoardDim
{
private static CellState[,] Board { get; set; }
public int BoardWidth { get; }
public int BoardHeight { get; }
private bool _minesSet;
public BoardDim(int boardHeight, int boardWidth)
{
if (boardHeight > 7 || boardWidth > 7)
{
BoardHeight = boardHeight;
BoardWidth = boardWidth;
// initialize the board
Board = new CellState[boardHeight, boardWidth];
}
else
{
Console.WriteLine($"{boardHeight} & {boardWidth} is too small! Minimum 8x8");
throw new ArgumentException("Board size has to be at least 8x8!");
}
}
public CellState[,] GetBoard()
{
var result = new CellState[BoardHeight, BoardWidth];
Array.Copy(Board, result, Board.Length);
return result;
}
public void MinesLocator(int posY, int posX) //to generate mines randomly
{
int mineCount = 0;
Random random = new Random();
do
{
int mineY = random.Next(BoardHeight);
int mineX = random.Next(BoardWidth);
int[,] mineLoc = new int[mineY,mineX];
mineCount++;
}
while (mineCount < 7) ;
_minesSet = !_minesSet;
}
public void checkTile(int posY, int posX)
{
var done = -1;
do
{
//(Board[posY, posX] != CellState.Mine);
} while (done < 0);
//so, now I need to make this check tile to compare the user input and stored array
}
}
}
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>
</Project>
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v3.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v3.0": {
"Game/1.0.0": {
"runtime": {
"Game.dll": {}
}
}
}
},
"libraries": {
"Game/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}
\ No newline at end of file
//------------------------------------------------------------------------------
// <auto-generated>
// Generated by the MSBuild WriteCodeFragment class.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("Game")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("Game")]
[assembly: System.Reflection.AssemblyTitleAttribute("Game")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
acfd3102c95a32db8e5f2fa08aee8c40bba88b20
/Users/kalevkim/secureprogramming/IDoMinesweeper/Game/bin/Debug/netcoreapp3.0/Game.deps.json
/Users/kalevkim/secureprogramming/IDoMinesweeper/Game/bin/Debug/netcoreapp3.0/Game.dll
/Users/kalevkim/secureprogramming/IDoMinesweeper/Game/bin/Debug/netcoreapp3.0/Game.pdb
/Users/kalevkim/secureprogramming/IDoMinesweeper/Game/obj/Debug/netcoreapp3.0/Game.csprojAssemblyReference.cache
/Users/kalevkim/secureprogramming/IDoMinesweeper/Game/obj/Debug/netcoreapp3.0/Game.AssemblyInfoInputs.cache
/Users/kalevkim/secureprogramming/IDoMinesweeper/Game/obj/Debug/netcoreapp3.0/Game.AssemblyInfo.cs
/Users/kalevkim/secureprogramming/IDoMinesweeper/Game/obj/Debug/netcoreapp3.0/Game.dll
/Users/kalevkim/secureprogramming/IDoMinesweeper/Game/obj/Debug/netcoreapp3.0/Game.pdb
{
"version": 1,
"dgSpecHash": "nXLM4KqfFtk6bTIhs5eiUwAxct2Lbd2U6s0jB4u6BUmqypwIQTBBFs0716jjYMDdkyQkDjY5t2Iw7BylUyY5EA==",
"success": true
}
\ No newline at end of file
{
"format": 1,
"restore": {
"/Users/kalevkim/secureprogramming/IDoMinesweeper/Game/Game.csproj": {}
},
"projects": {
"/Users/kalevkim/secureprogramming/IDoMinesweeper/Game/Game.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "/Users/kalevkim/secureprogramming/IDoMinesweeper/Game/Game.csproj",
"projectName": "Game",
"projectPath": "/Users/kalevkim/secureprogramming/IDoMinesweeper/Game/Game.csproj",
"packagesPath": "/Users/kalevkim/.nuget/packages/",
"outputPath": "/Users/kalevkim/secureprogramming/IDoMinesweeper/Game/obj/",
"projectStyle": "PackageReference",
"fallbackFolders": [
"/usr/local/share/dotnet/sdk/NuGetFallbackFolder"
],
"configFilePaths": [
"/Users/kalevkim/.config/NuGet/NuGet.Config"
],
"originalTargetFrameworks": [
"netcoreapp3.0"
],
"sources": {
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"netcoreapp3.0": {
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"netcoreapp3.0": {
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48"
],
"assetTargetFallback": true,
"warn": true
}
}
}
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">/Users/kalevkim/.nuget/packages/</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">/Users/kalevkim/.nuget/packages/;/usr/local/share/dotnet/sdk/NuGetFallbackFolder</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">5.2.0</NuGetToolVersion>
</PropertyGroup>
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
</Project>
\ No newline at end of file
{
"version": 3,
"targets": {
".NETCoreApp,Version=v3.0": {}
},
"libraries": {},
"projectFileDependencyGroups": {
".NETCoreApp,Version=v3.0": []
},
"packageFolders": {
"/Users/kalevkim/.nuget/packages/": {},
"/usr/local/share/dotnet/sdk/NuGetFallbackFolder": {}
},
"project": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "/Users/kalevkim/secureprogramming/IDoMinesweeper/Game/Game.csproj",
"projectName": "Game",
"projectPath": "/Users/kalevkim/secureprogramming/IDoMinesweeper/Game/Game.csproj",
"packagesPath": "/Users/kalevkim/.nuget/packages/",
"outputPath": "/Users/kalevkim/secureprogramming/IDoMinesweeper/Game/obj/",
"projectStyle": "PackageReference",
"fallbackFolders": [
"/usr/local/share/dotnet/sdk/NuGetFallbackFolder"
],
"configFilePaths": [
"/Users/kalevkim/.config/NuGet/NuGet.Config"
],
"originalTargetFrameworks": [
"netcoreapp3.0"
],
"sources": {
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"netcoreapp3.0": {
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"netcoreapp3.0": {
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48"
],
"assetTargetFallback": true,
"warn": true
}
}
}
}
\ No newline at end of file
{
"version": "1.0.0",
"restore": {
"projectUniqueName": "/Users/kalevkim/secureprogramming/IDoMinesweeper/Game/Game.csproj",
"projectName": "Game",
"projectPath": "/Users/kalevkim/secureprogramming/IDoMinesweeper/Game/Game.csproj",
"outputPath": "/Users/kalevkim/secureprogramming/IDoMinesweeper/Game/obj/",
"projectStyle": "PackageReference",
"fallbackFolders": [
"/usr/local/share/dotnet/sdk/NuGetFallbackFolder"
],
"originalTargetFrameworks": [
"netcoreapp3.0"
],
"sources": {
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"netcoreapp3.0": {
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"netcoreapp3.0": {
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48"
],
"assetTargetFallback": true,
"warn": true
}
}
}
\ No newline at end of file

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IDoMinesweeper", "IDoMinesweeper\IDoMinesweeper.csproj", "{CA65777F-0BB6-44EE-B3CC-E751837EEC1F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MenuSystem", "MenuSystem\MenuSystem.csproj", "{36E54CC2-CE21-4FAD-A199-42E592AF0A49}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Game", "Game\Game.csproj", "{895C23C7-E758-4851-945B-B4DC6E9CD7A1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleUserInt", "ConsoleUserInt\ConsoleUserInt.csproj", "{1D5D431C-50E6-4A85-A93C-A238941DD2A5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{CA65777F-0BB6-44EE-B3CC-E751837EEC1F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CA65777F-0BB6-44EE-B3CC-E751837EEC1F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CA65777F-0BB6-44EE-B3CC-E751837EEC1F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CA65777F-0BB6-44EE-B3CC-E751837EEC1F}.Release|Any CPU.Build.0 = Release|Any CPU
{36E54CC2-CE21-4FAD-A199-42E592AF0A49}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{36E54CC2-CE21-4FAD-A199-42E592AF0A49}.Debug|Any CPU.Build.0 = Debug|Any CPU
{36E54CC2-CE21-4FAD-A199-42E592AF0A49}.Release|Any CPU.ActiveCfg = Release|Any CPU
{36E54CC2-CE21-4FAD-A199-42E592AF0A49}.Release|Any CPU.Build.0 = Release|Any CPU
{895C23C7-E758-4851-945B-B4DC6E9CD7A1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{895C23C7-E758-4851-945B-B4DC6E9CD7A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{895C23C7-E758-4851-945B-B4DC6E9CD7A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{895C23C7-E758-4851-945B-B4DC6E9CD7A1}.Release|Any CPU.Build.0 = Release|Any CPU
{1D5D431C-50E6-4A85-A93C-A238941DD2A5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1D5D431C-50E6-4A85-A93C-A238941DD2A5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1D5D431C-50E6-4A85-A93C-A238941DD2A5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1D5D431C-50E6-4A85-A93C-A238941DD2A5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\ConsoleUserInt\ConsoleUserInt.csproj" />
<ProjectReference Include="..\Game\Game.csproj" />
<ProjectReference Include="..\MenuSystem\MenuSystem.csproj" />
</ItemGroup>
</Project>
using System;
using System.Collections.Generic;
using ConsoleUserInt.ConsoleUI;
using Engine;
using MenuSystem;
using static System.Console;
namespace IDoMinesweeper
{
class Program
{
static void Main(string[] args)
{
Clear();
WriteLine("Welcome to Minesweeper");
var gameMenu = new Menu(1)
{
Title = "New Game",
MenuItemsDictionary = new Dictionary<string, MenuItem>()
{
{
"1", new MenuItem()
{
Title = "Level 1",
CommandToExecute = null
}
},
{
"2", new MenuItem()
{
Title = "Level 2",
CommandToExecute = null
}
},
{
"3", new MenuItem()
{
Title = "Customize Your Board size",
CommandToExecute = TestGame
}
},
}
};
var menu0 = new Menu(0) //main menu
{
Title = "Main Menu",
MenuItemsDictionary = new Dictionary<string, MenuItem>()
{
{
"S", new MenuItem()
{
Title = "Start game",
CommandToExecute = gameMenu.Run
}
},
{
"D", new MenuItem()
{
Title = "Donate",
CommandToExecute = null
}
}
}
};
menu0.Run();
static string TestGame()
{
// do do-while and if it's correct it'll be done. Otherwise, it's gonna keep asking for input''''
WriteLine("Board height (Min. 8): ");
WriteLine(">");
int height = Convert.ToInt32(ReadLine());
WriteLine("Board width (Min. 8): ");
WriteLine(">");
var width = Convert.ToInt32(ReadLine());
var doIt = false;
do
{
if (height < 8 || width < 8)
{
Console.WriteLine("Too small");
return "";
break;
}
else
{
doIt = true;
}
} while (doIt = false);
var game = new BoardDim(height, width);
//previously game
var done = false;
do{
Clear();
GameUI.PrintBoard(game);
game.MinesLocator(height, width);
Console.WriteLine("Check the tile");
Console.WriteLine("Y location:");
int playerMoveY = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("X location:");
int playerMoveX = Convert.ToInt32(Console.ReadLine());
game.checkTile(playerMoveY, playerMoveX);
//done = userYint == 0 && userXint == 0;
//done when it gets one mine at least. it'll turn the value from -1 to 0
done = true;
} while (!done);
return "GAME OVER!!";
}
}
}
}
\ No newline at end of file
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v3.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v3.0": {
"IDoMinesweeper/1.0.0": {
"dependencies": {
"ConsoleUserInt": "1.0.0",
"Game": "1.0.0",
"MenuSystem": "1.0.0"
},
"runtime": {
"IDoMinesweeper.dll": {}
}
},
"ConsoleUserInt/1.0.0": {
"dependencies": {
"Game": "1.0.0"
},
"runtime": {
"ConsoleUserInt.dll": {}
}
},
"Game/1.0.0": {
"runtime": {
"Game.dll": {}
}
},
"MenuSystem/1.0.0": {
"runtime": {
"MenuSystem.dll": {}
}
}
}
},
"libraries": {
"IDoMinesweeper/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"ConsoleUserInt/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"Game/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
},
"MenuSystem/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}
\ No newline at end of file
{
"runtimeOptions": {
"additionalProbingPaths": [
"/Users/kalevkim/.dotnet/store/|arch|/|tfm|",
"/Users/kalevkim/.nuget/packages",
"/usr/local/share/dotnet/sdk/NuGetFallbackFolder"
]
}
}
\ No newline at end of file
{
"runtimeOptions": {
"tfm": "netcoreapp3.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "3.0.0"
}
}
}
\ No newline at end of file
//------------------------------------------------------------------------------
// <auto-generated>
// Generated by the MSBuild WriteCodeFragment class.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("IDoMinesweeper")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("IDoMinesweeper")]
[assembly: System.Reflection.AssemblyTitleAttribute("IDoMinesweeper")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
/Users/kalevkim/secureprogramming/IDoMinesweeper/IDoMinesweeper/bin/Debug/netcoreapp3.0/IDoMinesweeper
/Users/kalevkim/secureprogramming/IDoMinesweeper/IDoMinesweeper/bin/Debug/netcoreapp3.0/IDoMinesweeper.deps.json
/Users/kalevkim/secureprogramming/IDoMinesweeper/IDoMinesweeper/bin/Debug/netcoreapp3.0/IDoMinesweeper.runtimeconfig.json
/Users/kalevkim/secureprogramming/IDoMinesweeper/IDoMinesweeper/bin/Debug/netcoreapp3.0/IDoMinesweeper.runtimeconfig.dev.json
/Users/kalevkim/secureprogramming/IDoMinesweeper/IDoMinesweeper/bin/Debug/netcoreapp3.0/IDoMinesweeper.dll
/Users/kalevkim/secureprogramming/IDoMinesweeper/IDoMinesweeper/bin/Debug/netcoreapp3.0/IDoMinesweeper.pdb
/Users/kalevkim/secureprogramming/IDoMinesweeper/IDoMinesweeper/obj/Debug/netcoreapp3.0/IDoMinesweeper.csprojAssemblyReference.cache
/Users/kalevkim/secureprogramming/IDoMinesweeper/IDoMinesweeper/obj/Debug/netcoreapp3.0/IDoMinesweeper.AssemblyInfoInputs.cache
/Users/kalevkim/secureprogramming/IDoMinesweeper/IDoMinesweeper/obj/Debug/netcoreapp3.0/IDoMinesweeper.AssemblyInfo.cs
/Users/kalevkim/secureprogramming/IDoMinesweeper/IDoMinesweeper/obj/Debug/netcoreapp3.0/IDoMinesweeper.dll
/Users/kalevkim/secureprogramming/IDoMinesweeper/IDoMinesweeper/obj/Debug/netcoreapp3.0/IDoMinesweeper.pdb
/Users/kalevkim/secureprogramming/IDoMinesweeper/IDoMinesweeper/bin/Debug/netcoreapp3.0/MenuSystem.dll
/Users/kalevkim/secureprogramming/IDoMinesweeper/IDoMinesweeper/bin/Debug/netcoreapp3.0/MenuSystem.pdb
/Users/kalevkim/secureprogramming/IDoMinesweeper/IDoMinesweeper/obj/Debug/netcoreapp3.0/IDoMinesweeper.csproj.CopyComplete
/Users/kalevkim/secureprogramming/IDoMinesweeper/IDoMinesweeper/bin/Debug/netcoreapp3.0/ConsoleUserInt.dll
/Users/kalevkim/secureprogramming/IDoMinesweeper/IDoMinesweeper/bin/Debug/netcoreapp3.0/Game.dll
/Users/kalevkim/secureprogramming/IDoMinesweeper/IDoMinesweeper/bin/Debug/netcoreapp3.0/ConsoleUserInt.pdb
/Users/kalevkim/secureprogramming/IDoMinesweeper/IDoMinesweeper/bin/Debug/netcoreapp3.0/Game.pdb
{
"version": 1,
"dgSpecHash": "wiqMLxMh6d4xGEN9mwNfnv8kqAlbM6pQlGxFOEczSsdVD4elFb5W/C5+rrHGWxVE0LpFETEMD97RWTRmL7RcHA==",
"success": true
}
\ No newline at end of file
{
"format": 1,
"restore": {
"/Users/kalevkim/secureprogramming/IDoMinesweeper/IDoMinesweeper/IDoMinesweeper.csproj": {}
},
"projects": {
"/Users/kalevkim/secureprogramming/IDoMinesweeper/ConsoleUserInt/ConsoleUserInt.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "/Users/kalevkim/secureprogramming/IDoMinesweeper/ConsoleUserInt/ConsoleUserInt.csproj",
"projectName": "ConsoleUserInt",
"projectPath": "/Users/kalevkim/secureprogramming/IDoMinesweeper/ConsoleUserInt/ConsoleUserInt.csproj",
"packagesPath": "/Users/kalevkim/.nuget/packages/",
"outputPath": "/Users/kalevkim/secureprogramming/IDoMinesweeper/ConsoleUserInt/obj/",
"projectStyle": "PackageReference",
"fallbackFolders": [
"/usr/local/share/dotnet/sdk/NuGetFallbackFolder"
],
"configFilePaths": [
"/Users/kalevkim/.config/NuGet/NuGet.Config"
],
"originalTargetFrameworks": [
"netcoreapp3.0"
],
"sources": {
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"netcoreapp3.0": {
"projectReferences": {
"/Users/kalevkim/secureprogramming/IDoMinesweeper/Game/Game.csproj": {
"projectPath": "/Users/kalevkim/secureprogramming/IDoMinesweeper/Game/Game.csproj"
}
}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"netcoreapp3.0": {
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48"
],
"assetTargetFallback": true,
"warn": true
}
}
},
"/Users/kalevkim/secureprogramming/IDoMinesweeper/Game/Game.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "/Users/kalevkim/secureprogramming/IDoMinesweeper/Game/Game.csproj",
"projectName": "Game",
"projectPath": "/Users/kalevkim/secureprogramming/IDoMinesweeper/Game/Game.csproj",
"packagesPath": "/Users/kalevkim/.nuget/packages/",
"outputPath": "/Users/kalevkim/secureprogramming/IDoMinesweeper/Game/obj/",
"projectStyle": "PackageReference",
"fallbackFolders": [
"/usr/local/share/dotnet/sdk/NuGetFallbackFolder"
],
"configFilePaths": [
"/Users/kalevkim/.config/NuGet/NuGet.Config"
],
"originalTargetFrameworks": [
"netcoreapp3.0"
],
"sources": {
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"netcoreapp3.0": {
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"netcoreapp3.0": {
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48"
],
"assetTargetFallback": true,
"warn": true
}
}
},
"/Users/kalevkim/secureprogramming/IDoMinesweeper/IDoMinesweeper/IDoMinesweeper.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "/Users/kalevkim/secureprogramming/IDoMinesweeper/IDoMinesweeper/IDoMinesweeper.csproj",
"projectName": "IDoMinesweeper",
"projectPath": "/Users/kalevkim/secureprogramming/IDoMinesweeper/IDoMinesweeper/IDoMinesweeper.csproj",
"packagesPath": "/Users/kalevkim/.nuget/packages/",
"outputPath": "/Users/kalevkim/secureprogramming/IDoMinesweeper/IDoMinesweeper/obj/",
"projectStyle": "PackageReference",
"fallbackFolders": [
"/usr/local/share/dotnet/sdk/NuGetFallbackFolder"
],
"configFilePaths": [
"/Users/kalevkim/.config/NuGet/NuGet.Config"
],
"originalTargetFrameworks": [
"netcoreapp3.0"
],
"sources": {
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"netcoreapp3.0": {
"projectReferences": {
"/Users/kalevkim/secureprogramming/IDoMinesweeper/ConsoleUserInt/ConsoleUserInt.csproj": {
"projectPath": "/Users/kalevkim/secureprogramming/IDoMinesweeper/ConsoleUserInt/ConsoleUserInt.csproj"
},
"/Users/kalevkim/secureprogramming/IDoMinesweeper/Game/Game.csproj": {
"projectPath": "/Users/kalevkim/secureprogramming/IDoMinesweeper/Game/Game.csproj"
},
"/Users/kalevkim/secureprogramming/IDoMinesweeper/MenuSystem/MenuSystem.csproj": {
"projectPath": "/Users/kalevkim/secureprogramming/IDoMinesweeper/MenuSystem/MenuSystem.csproj"
}
}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"netcoreapp3.0": {
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48"
],
"assetTargetFallback": true,
"warn": true
}
}
},
"/Users/kalevkim/secureprogramming/IDoMinesweeper/MenuSystem/MenuSystem.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "/Users/kalevkim/secureprogramming/IDoMinesweeper/MenuSystem/MenuSystem.csproj",
"projectName": "MenuSystem",
"projectPath": "/Users/kalevkim/secureprogramming/IDoMinesweeper/MenuSystem/MenuSystem.csproj",
"packagesPath": "/Users/kalevkim/.nuget/packages/",
"outputPath": "/Users/kalevkim/secureprogramming/IDoMinesweeper/MenuSystem/obj/",
"projectStyle": "PackageReference",
"fallbackFolders": [
"/usr/local/share/dotnet/sdk/NuGetFallbackFolder"
],
"configFilePaths": [
"/Users/kalevkim/.config/NuGet/NuGet.Config"
],
"originalTargetFrameworks": [
"netcoreapp3.0"
],
"sources": {
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"netcoreapp3.0": {
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"netcoreapp3.0": {
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48"
],
"assetTargetFallback": true,
"warn": true
}
}
}
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">/Users/kalevkim/.nuget/packages/</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">/Users/kalevkim/.nuget/packages/;/usr/local/share/dotnet/sdk/NuGetFallbackFolder</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">5.2.0</NuGetToolVersion>
</PropertyGroup>
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
</Project>
\ No newline at end of file
{
"version": 3,
"targets": {
".NETCoreApp,Version=v3.0": {
"ConsoleUserInt/1.0.0": {
"type": "project",
"framework": ".NETCoreApp,Version=v3.0",
"dependencies": {
"Game": "1.0.0"
},
"compile": {
"bin/placeholder/ConsoleUserInt.dll": {}
},
"runtime": {
"bin/placeholder/ConsoleUserInt.dll": {}
}
},
"Game/1.0.0": {
"type": "project",
"framework": ".NETCoreApp,Version=v3.0",
"compile": {
"bin/placeholder/Game.dll": {}
},
"runtime": {
"bin/placeholder/Game.dll": {}
}
},
"MenuSystem/1.0.0": {
"type": "project",
"framework": ".NETCoreApp,Version=v3.0",
"compile": {
"bin/placeholder/MenuSystem.dll": {}
},
"runtime": {
"bin/placeholder/MenuSystem.dll": {}
}
}
}
},
"libraries": {
"ConsoleUserInt/1.0.0": {
"type": "project",
"path": "../ConsoleUserInt/ConsoleUserInt.csproj",
"msbuildProject": "../ConsoleUserInt/ConsoleUserInt.csproj"
},
"Game/1.0.0": {
"type": "project",
"path": "../Game/Game.csproj",
"msbuildProject": "../Game/Game.csproj"
},
"MenuSystem/1.0.0": {
"type": "project",
"path": "../MenuSystem/MenuSystem.csproj",
"msbuildProject": "../MenuSystem/MenuSystem.csproj"
}
},
"projectFileDependencyGroups": {
".NETCoreApp,Version=v3.0": [
"ConsoleUserInt >= 1.0.0",
"Game >= 1.0.0",
"MenuSystem >= 1.0.0"
]
},
"packageFolders": {
"/Users/kalevkim/.nuget/packages/": {},
"/usr/local/share/dotnet/sdk/NuGetFallbackFolder": {}
},
"project": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "/Users/kalevkim/secureprogramming/IDoMinesweeper/IDoMinesweeper/IDoMinesweeper.csproj",
"projectName": "IDoMinesweeper",
"projectPath": "/Users/kalevkim/secureprogramming/IDoMinesweeper/IDoMinesweeper/IDoMinesweeper.csproj",
"packagesPath": "/Users/kalevkim/.nuget/packages/",
"outputPath": "/Users/kalevkim/secureprogramming/IDoMinesweeper/IDoMinesweeper/obj/",
"projectStyle": "PackageReference",
"fallbackFolders": [
"/usr/local/share/dotnet/sdk/NuGetFallbackFolder"
],
"configFilePaths": [
"/Users/kalevkim/.config/NuGet/NuGet.Config"
],
"originalTargetFrameworks": [
"netcoreapp3.0"
],
"sources": {
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"netcoreapp3.0": {
"projectReferences": {
"/Users/kalevkim/secureprogramming/IDoMinesweeper/ConsoleUserInt/ConsoleUserInt.csproj": {
"projectPath": "/Users/kalevkim/secureprogramming/IDoMinesweeper/ConsoleUserInt/ConsoleUserInt.csproj"
},
"/Users/kalevkim/secureprogramming/IDoMinesweeper/Game/Game.csproj": {
"projectPath": "/Users/kalevkim/secureprogramming/IDoMinesweeper/Game/Game.csproj"
},
"/Users/kalevkim/secureprogramming/IDoMinesweeper/MenuSystem/MenuSystem.csproj": {
"projectPath": "/Users/kalevkim/secureprogramming/IDoMinesweeper/MenuSystem/MenuSystem.csproj"
}
}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"netcoreapp3.0": {
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48"
],
"assetTargetFallback": true,
"warn": true
}
}
}
}
\ No newline at end of file
{
"version": "1.0.0",
"restore": {
"projectUniqueName": "/Users/kalevkim/secureprogramming/IDoMinesweeper/IDoMinesweeper/IDoMinesweeper.csproj",
"projectName": "IDoMinesweeper",
"projectPath": "/Users/kalevkim/secureprogramming/IDoMinesweeper/IDoMinesweeper/IDoMinesweeper.csproj",
"outputPath": "/Users/kalevkim/secureprogramming/IDoMinesweeper/IDoMinesweeper/obj/",
"projectStyle": "PackageReference",
"fallbackFolders": [
"/usr/local/share/dotnet/sdk/NuGetFallbackFolder"
],
"originalTargetFrameworks": [
"netcoreapp3.0"
],
"sources": {
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"netcoreapp3.0": {
"projectReferences": {
"/Users/kalevkim/secureprogramming/IDoMinesweeper/ConsoleUserInt/ConsoleUserInt.csproj": {
"projectPath": "/Users/kalevkim/secureprogramming/IDoMinesweeper/ConsoleUserInt/ConsoleUserInt.csproj"
},
"/Users/kalevkim/secureprogramming/IDoMinesweeper/Game/Game.csproj": {
"projectPath": "/Users/kalevkim/secureprogramming/IDoMinesweeper/Game/Game.csproj"
},
"/Users/kalevkim/secureprogramming/IDoMinesweeper/MenuSystem/MenuSystem.csproj": {
"projectPath": "/Users/kalevkim/secureprogramming/IDoMinesweeper/MenuSystem/MenuSystem.csproj"
}
}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"netcoreapp3.0": {
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48"
],
"assetTargetFallback": true,
"warn": true
}
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Security.Cryptography.X509Certificates;
namespace MenuSystem
{
public class Menu
{
private int _menuLevel;
private const string MenuCommandExit = "X";
private const string MenuCommandReturnToPrevious = "P";
private Dictionary<string, MenuItem> _menuItemsDictionary = new Dictionary<string, MenuItem>();
public Menu(int menuLevel = 0)
{
_menuLevel = menuLevel;
}
public string Title { get; set; }
public Dictionary<string, MenuItem> MenuItemsDictionary
{
get => _menuItemsDictionary;
set
{
_menuItemsDictionary = value;
if (_menuLevel >= 2)
{
_menuItemsDictionary.Add(MenuCommandReturnToPrevious, new MenuItem() {Title = "Back"});
}
if (_menuLevel >= 1)
{
_menuItemsDictionary.Add(MenuCommandExit, new MenuItem() {Title = "Exit"});
}
}
}
public string Run()
{
var command = "";
do
{
Console.WriteLine(Title);
Console.WriteLine("========================");
foreach (var menuItem in MenuItemsDictionary)
{
Console.Write(menuItem.Key);
Console.Write(" ");
Console.WriteLine(menuItem.Value);
}
Console.WriteLine("----------");
Console.Write(">");
command = Console.ReadLine()?.Trim().ToUpper() ?? "";
var returnCommand = "";
if (MenuItemsDictionary.ContainsKey(command))
{
var menuItem = MenuItemsDictionary[command];
if (menuItem.CommandToExecute != null)
{
returnCommand = menuItem.CommandToExecute(); // run the command
break;
}
}
if (returnCommand == MenuCommandExit)
{
command = MenuCommandExit;
}
} while (command != MenuCommandExit &&
command != MenuCommandReturnToPrevious);
return command;
}
}
}
\ No newline at end of file
using System;
namespace MenuSystem
{
public class MenuItem
{
private string _title;
public string Title
{
get => _title;
set => _title = Validate(value, 1, 100, false);
}
// reference to an method, which returns a string and takes no parameters
// func<...parameter types..., return type>
public Func<string> CommandToExecute { get; set; }
private static string Validate(string item, int minLength, int maxLength, bool toUpper)
{
item = item.Trim();
if (toUpper)
{
item = item.ToUpper();
}
if (item.Length < minLength || item.Length > maxLength)
{
throw new ArgumentException(
$"String is not correct length (" +
$"{minLength}-{maxLength})! Got " +
$"{item.Length} characters.");
}
return item;
}
public override string ToString()
{
return Title;
}
}
}
\ No newline at end of file
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>
</Project>
{
"runtimeTarget": {
"name": ".NETCoreApp,Version=v3.0",
"signature": ""
},
"compilationOptions": {},
"targets": {
".NETCoreApp,Version=v3.0": {
"MenuSystem/1.0.0": {
"runtime": {
"MenuSystem.dll": {}
}
}
}
},
"libraries": {
"MenuSystem/1.0.0": {
"type": "project",
"serviceable": false,
"sha512": ""
}
}
}
\ No newline at end of file
//------------------------------------------------------------------------------
// <auto-generated>
// Generated by the MSBuild WriteCodeFragment class.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("MenuSystem")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
[assembly: System.Reflection.AssemblyProductAttribute("MenuSystem")]
[assembly: System.Reflection.AssemblyTitleAttribute("MenuSystem")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
/Users/kalevkim/secureprogramming/IDoMinesweeper/MenuSystem/bin/Debug/netcoreapp3.0/MenuSystem.deps.json
/Users/kalevkim/secureprogramming/IDoMinesweeper/MenuSystem/bin/Debug/netcoreapp3.0/MenuSystem.dll
/Users/kalevkim/secureprogramming/IDoMinesweeper/MenuSystem/bin/Debug/netcoreapp3.0/MenuSystem.pdb
/Users/kalevkim/secureprogramming/IDoMinesweeper/MenuSystem/obj/Debug/netcoreapp3.0/MenuSystem.csprojAssemblyReference.cache
/Users/kalevkim/secureprogramming/IDoMinesweeper/MenuSystem/obj/Debug/netcoreapp3.0/MenuSystem.AssemblyInfoInputs.cache
/Users/kalevkim/secureprogramming/IDoMinesweeper/MenuSystem/obj/Debug/netcoreapp3.0/MenuSystem.AssemblyInfo.cs
/Users/kalevkim/secureprogramming/IDoMinesweeper/MenuSystem/obj/Debug/netcoreapp3.0/MenuSystem.dll
/Users/kalevkim/secureprogramming/IDoMinesweeper/MenuSystem/obj/Debug/netcoreapp3.0/MenuSystem.pdb
{
"version": 1,
"dgSpecHash": "fJkuEZ8ALadATxeapGqYaT6y1KPJmdzzYFvSTNv3jytlddB/FL74traiM3Lk5VHbxVF8k0J+xghk58TdfGSK7A==",
"success": true
}
\ No newline at end of file
{
"format": 1,
"restore": {
"/Users/kalevkim/secureprogramming/IDoMinesweeper/MenuSystem/MenuSystem.csproj": {}
},
"projects": {
"/Users/kalevkim/secureprogramming/IDoMinesweeper/MenuSystem/MenuSystem.csproj": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "/Users/kalevkim/secureprogramming/IDoMinesweeper/MenuSystem/MenuSystem.csproj",
"projectName": "MenuSystem",
"projectPath": "/Users/kalevkim/secureprogramming/IDoMinesweeper/MenuSystem/MenuSystem.csproj",
"packagesPath": "/Users/kalevkim/.nuget/packages/",
"outputPath": "/Users/kalevkim/secureprogramming/IDoMinesweeper/MenuSystem/obj/",
"projectStyle": "PackageReference",
"fallbackFolders": [
"/usr/local/share/dotnet/sdk/NuGetFallbackFolder"
],
"configFilePaths": [
"/Users/kalevkim/.config/NuGet/NuGet.Config"
],
"originalTargetFrameworks": [
"netcoreapp3.0"
],
"sources": {
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"netcoreapp3.0": {
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"netcoreapp3.0": {
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48"
],
"assetTargetFallback": true,
"warn": true
}
}
}
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">/Users/kalevkim/.nuget/packages/</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">/Users/kalevkim/.nuget/packages/;/usr/local/share/dotnet/sdk/NuGetFallbackFolder</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">5.2.0</NuGetToolVersion>
</PropertyGroup>
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
</Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
</Project>
\ No newline at end of file
{
"version": 3,
"targets": {
".NETCoreApp,Version=v3.0": {}
},
"libraries": {},
"projectFileDependencyGroups": {
".NETCoreApp,Version=v3.0": []
},
"packageFolders": {
"/Users/kalevkim/.nuget/packages/": {},
"/usr/local/share/dotnet/sdk/NuGetFallbackFolder": {}
},
"project": {
"version": "1.0.0",
"restore": {
"projectUniqueName": "/Users/kalevkim/secureprogramming/IDoMinesweeper/MenuSystem/MenuSystem.csproj",
"projectName": "MenuSystem",
"projectPath": "/Users/kalevkim/secureprogramming/IDoMinesweeper/MenuSystem/MenuSystem.csproj",
"packagesPath": "/Users/kalevkim/.nuget/packages/",
"outputPath": "/Users/kalevkim/secureprogramming/IDoMinesweeper/MenuSystem/obj/",
"projectStyle": "PackageReference",
"fallbackFolders": [
"/usr/local/share/dotnet/sdk/NuGetFallbackFolder"
],
"configFilePaths": [
"/Users/kalevkim/.config/NuGet/NuGet.Config"
],
"originalTargetFrameworks": [
"netcoreapp3.0"
],
"sources": {
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"netcoreapp3.0": {
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"netcoreapp3.0": {
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48"
],
"assetTargetFallback": true,
"warn": true
}
}
}
}
\ No newline at end of file
{
"version": "1.0.0",
"restore": {
"projectUniqueName": "/Users/kalevkim/secureprogramming/IDoMinesweeper/MenuSystem/MenuSystem.csproj",
"projectName": "MenuSystem",
"projectPath": "/Users/kalevkim/secureprogramming/IDoMinesweeper/MenuSystem/MenuSystem.csproj",
"outputPath": "/Users/kalevkim/secureprogramming/IDoMinesweeper/MenuSystem/obj/",
"projectStyle": "PackageReference",
"fallbackFolders": [
"/usr/local/share/dotnet/sdk/NuGetFallbackFolder"
],
"originalTargetFrameworks": [
"netcoreapp3.0"
],
"sources": {
"https://api.nuget.org/v3/index.json": {}
},
"frameworks": {
"netcoreapp3.0": {
"projectReferences": {}
}
},
"warningProperties": {
"warnAsError": [
"NU1605"
]
}
},
"frameworks": {
"netcoreapp3.0": {
"imports": [
"net461",
"net462",
"net47",
"net471",
"net472",
"net48"
],
"assetTargetFallback": true,
"warn": true
}
}
}
\ No newline at end of file
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