Adding Method Displayer, and renaming projects

This commit is contained in:
2025-08-06 14:25:08 +02:00
parent bb32e873c1
commit 866628af59
16 changed files with 71 additions and 39 deletions

View File

@@ -1,27 +0,0 @@
namespace BasicProgramming
{
public class Program
{
static void Main(string[] args)
{
var methodCollections = new List<IMethodCollection>()
{
new Basic(),
new Statement(),
new Loops(),
new Strings()
};
methodCollections.ForEach(x =>
{
Console.WriteLine($"====== {x.GetType().Name} ======");
x.DisplayAllMethods();
});
}
}
public interface IMethodCollection
{
public void DisplayAllMethods();
}
}

View File

@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="../MethodLibrary/MethodLibrary.csproj" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,24 @@
using MethodLibrary;
namespace MethodDisplayer
{
public class Program
{
static void Main(string[] args)
{
var methodCollections = new List<IMethodCollection>
{
new Basic(),
new Statement(),
new Loops(),
new Strings()
};
foreach (var method in methodCollections)
{
Console.WriteLine($"====== {method.GetType().Name} ======");
method.DisplayAllMethods();
}
}
}
}

View File

@@ -2,9 +2,11 @@
# Visual Studio Version 17 # Visual Studio Version 17
VisualStudioVersion = 17.5.2.0 VisualStudioVersion = 17.5.2.0
MinimumVisualStudioVersion = 10.0.40219.1 MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BasicProgramming", "BasicProgramming\BasicProgramming.csproj", "{F852DB4D-952E-CFAF-DFC6-298FB48C8A28}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MethodLibrary", "MethodLibrary\MethodLibrary.csproj", "{F852DB4D-952E-CFAF-DFC6-298FB48C8A28}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BasicProgrammingTests", "BasicProgrammingUnitTest\BasicProgrammingTests.csproj", "{427B1690-1D9B-4002-A6DE-435867230BAC}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MethodLibraryTests", "MethodLibraryTests\MethodLibraryTests.csproj", "{427B1690-1D9B-4002-A6DE-435867230BAC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MethodDisplayer", "MethodDisplayer\MethodDisplayer.csproj", "{204AEF70-C8DC-4FB7-A2F6-D4BAEBBA20EB}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -20,6 +22,10 @@ Global
{427B1690-1D9B-4002-A6DE-435867230BAC}.Debug|Any CPU.Build.0 = Debug|Any CPU {427B1690-1D9B-4002-A6DE-435867230BAC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{427B1690-1D9B-4002-A6DE-435867230BAC}.Release|Any CPU.ActiveCfg = Release|Any CPU {427B1690-1D9B-4002-A6DE-435867230BAC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{427B1690-1D9B-4002-A6DE-435867230BAC}.Release|Any CPU.Build.0 = Release|Any CPU {427B1690-1D9B-4002-A6DE-435867230BAC}.Release|Any CPU.Build.0 = Release|Any CPU
{204AEF70-C8DC-4FB7-A2F6-D4BAEBBA20EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{204AEF70-C8DC-4FB7-A2F6-D4BAEBBA20EB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{204AEF70-C8DC-4FB7-A2F6-D4BAEBBA20EB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{204AEF70-C8DC-4FB7-A2F6-D4BAEBBA20EB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@@ -1,4 +1,4 @@
namespace BasicProgramming namespace MethodLibrary
{ {
public class Basic : IMethodCollection public class Basic : IMethodCollection
{ {

View File

@@ -0,0 +1,7 @@
namespace MethodLibrary
{
public interface IMethodCollection
{
public void DisplayAllMethods();
}
}

View File

@@ -1,7 +1,7 @@
using System.Text; using System.Text;
using System.Text.Json; using System.Text.Json;
namespace BasicProgramming namespace MethodLibrary
{ {
public class Loops : IMethodCollection public class Loops : IMethodCollection
{ {

View File

@@ -1,6 +1,6 @@
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
namespace BasicProgramming namespace MethodLibrary
{ {
public class Statement : IMethodCollection public class Statement : IMethodCollection
{ {

View File

@@ -1,7 +1,7 @@
using System.Text; using System.Text;
using System.Text.Json; using System.Text.Json;
namespace BasicProgramming namespace MethodLibrary
{ {
public class Strings : IMethodCollection public class Strings : IMethodCollection
{ {

View File

@@ -1,4 +1,4 @@
using BasicProgramming; using MethodLibrary;
namespace BasicProgrammingTests; namespace BasicProgrammingTests;

View File

@@ -1,4 +1,4 @@
using BasicProgramming; using MethodLibrary;
namespace BasicProgrammingTests; namespace BasicProgrammingTests;

View File

@@ -14,8 +14,8 @@
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2" /> <PackageReference Include="xunit.runner.visualstudio" Version="2.8.2" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="../BasicProgramming/BasicProgramming.csproj" /> <ProjectReference Include="../MethodLibrary/MethodLibrary.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -1,4 +1,4 @@
using BasicProgramming; using MethodLibrary;
namespace BasicProgrammingTests; namespace BasicProgrammingTests;

View File

@@ -1,4 +1,4 @@
using BasicProgramming; using MethodLibrary;
namespace BasicProgrammingTests; namespace BasicProgrammingTests;

View File

@@ -1 +1,9 @@
# Basic Programming # Basic Programming
Velkommen til projektet hvor jeg måske har overengineeret en smule meget.
Det er et par skole opgaver, hvor man skulle skrive nogle metoder, og derefter lave unit tests.
Jeg har måske kommet til at tage det skridtet videre.
Der er blevet lavet en klasse til hver opgave, så Basic opgaven har klassen Basic osv. Herefter er der blevet implementeret et interface på alle klasserne som jeg kalder en Metode Collection, som sørger for at alle klasserne, har en metode som skriver alle test scenarier ud i konsollen. Dette kan listen i Program.cs bruge til at sørge for at alle Metoder bliver printet i konsolen.