Commit f212cc65 authored by Andres Käver's avatar Andres Käver
Browse files

Initial commit

parents
bin/
obj/
/packages/
riderModule.iml
/_ReSharper.Caches/
\ No newline at end of file
# Default ignored files
/shelf/
/workspace.xml
# Rider ignored files
/modules.xml
/contentModel.xml
/.idea.CSharpDemo21f.iml
/projectSettingsUpdater.xml
# Editor-based HTTP Client requests
/httpRequests/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
<?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="UserContentModel">
<attachedFolders />
<explicitIncludes />
<explicitExcludes />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
</project>
\ No newline at end of file

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConsoleApp", "ConsoleApp\ConsoleApp.csproj", "{94920F6C-C9F6-4B95-B3BE-1C115574DFF8}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MenuSystem", "MenuSystem\MenuSystem.csproj", "{3D6B86AF-3A4D-4145-A2D8-57FE6AF4CADF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{94920F6C-C9F6-4B95-B3BE-1C115574DFF8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{94920F6C-C9F6-4B95-B3BE-1C115574DFF8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{94920F6C-C9F6-4B95-B3BE-1C115574DFF8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{94920F6C-C9F6-4B95-B3BE-1C115574DFF8}.Release|Any CPU.Build.0 = Release|Any CPU
{3D6B86AF-3A4D-4145-A2D8-57FE6AF4CADF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3D6B86AF-3A4D-4145-A2D8-57FE6AF4CADF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3D6B86AF-3A4D-4145-A2D8-57FE6AF4CADF}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3D6B86AF-3A4D-4145-A2D8-57FE6AF4CADF}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\MenuSystem\MenuSystem.csproj" />
</ItemGroup>
</Project>
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using MenuSystem;
namespace ConsoleApp
{
class Program
{
static void Main(string[] args)
{
Console.Clear();
Console.WriteLine("Hello Calc!");
var mainMenu = new Menu();
mainMenu.MenuItems = new List<MenuItem>()
{
new MenuItem("A", "Aaaaaaaaa"),
new MenuItem("B", "BBBBB"),
new MenuItem("C", "Cccccc"),
};
mainMenu.Run();
var choice = MainMenu();
Console.WriteLine("done! " + choice);
}
static string MainMenu()
{
var userChoice = "";
var done = false;
do
{
done = false;
Console.WriteLine("Current value: 0");
Console.WriteLine("C) Classical operations");
Console.WriteLine("W) Weird stuff");
Console.WriteLine("N) Enter number");
Console.WriteLine("----------------");
Console.WriteLine("E) Exit");
Console.WriteLine("================");
Console.Write("Your choice:>");
userChoice = Console
.ReadLine()?
.Trim()
.ToUpper()
?? "";
switch (userChoice)
{
case "C":
done = true;
break;
case "W":
done = true;
break;
case "N":
done = true;
break;
case "E":
done = true;
break;
}
} while (!done);
return userChoice;
}
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
namespace MenuSystem
{
public class Menu
{
public List<MenuItem> MenuItems { get; set; } = new List<MenuItem>();
public string Run()
{
OutputMenu();
return "";
}
private void OutputMenu()
{
foreach (var t in MenuItems)
{
Console.WriteLine(t);
}
Console.WriteLine("-------------------");
}
}
}
\ No newline at end of file
using System;
namespace MenuSystem
{
public class MenuItem
{
public MenuItem(string shortCut, string title)
{
if (string.IsNullOrEmpty(shortCut))
{
throw new ArgumentException("shortCut cannot be empty!");
}
if (string.IsNullOrEmpty(title))
{
throw new ArgumentException("title cannot be empty!");
}
ShortCut = shortCut.Trim();
Title = title.Trim();
}
public string Title { get; private set; }
public string ShortCut { get; private set; }
public override string ToString()
{
return ShortCut + ") " + Title;
}
}
}
\ No newline at end of file
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
</Project>
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 to comment