Skip to content

Commit d8d5623

Browse files
committed
add interface and adjust startup parameters
1 parent a3549c9 commit d8d5623

File tree

4 files changed

+62
-2
lines changed

4 files changed

+62
-2
lines changed

2022/Day01/solution.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,22 @@
11
using System;
2+
using adventofcode;
23

34
namespace aoc2022;
4-
public class solutionDay01
5+
public class solutionDay01 : ISolver
56
{
67
public void Solve()
78
{
89
Console.WriteLine("solve test");
910
}
11+
12+
public void SolvePart1()
13+
{
14+
Console.WriteLine("try to solve first part");
15+
}
16+
17+
public void SolvePart2()
18+
{
19+
Console.WriteLine("try to solve second part");
20+
}
1021
}
1122

ISolver.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
namespace adventofcode;
2+
3+
interface ISolver
4+
{
5+
public void SolvePart1();
6+
7+
public void SolvePart2();
8+
}

Program.cs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ static void Main(string[] args)
2424

2525
solve(year, day, part);
2626
}
27+
else if (args.Length == 2)
28+
{
29+
year = Convert.ToInt32(args[0]);
30+
day = Convert.ToInt32(args[1]);
31+
solve(year, day);
32+
}
2733
else
2834
{
2935
//solutionDay1 sd1 = new solutionDay1(2);
@@ -42,6 +48,13 @@ static void Main(string[] args)
4248
//Console.Read();
4349
}
4450

51+
static void solve(int year, int day)
52+
{
53+
solve(year, day, 1);
54+
55+
solve(year, day, 2);
56+
}
57+
4558
static void solve(int year, int day, int part)
4659
{
4760
if(year == 2022)
@@ -51,10 +64,13 @@ static void solve(int year, int day, int part)
5164

5265
Console.WriteLine("{0}", assembly.FullName);
5366

67+
var solution = $"aoc{year.ToString("D4")}.solutionDay{day.ToString("D2")}";
68+
Console.WriteLine(solution);
69+
5470
Type type = assembly.GetType("aoc2022.solutionDay01");
5571
object instance = Activator.CreateInstance(type);
5672

57-
MethodInfo solve = type.GetMethod("Solve");
73+
MethodInfo solve = type.GetMethod($"SolvePart{part.ToString("D1")}");
5874

5975
solve.Invoke(instance, null);
6076

adventofcode.sln

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.5.002.0
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "adventofcode", "adventofcode.csproj", "{A10E754C-6C5C-47F2-BB15-A65DD7D8137E}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{A10E754C-6C5C-47F2-BB15-A65DD7D8137E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{A10E754C-6C5C-47F2-BB15-A65DD7D8137E}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{A10E754C-6C5C-47F2-BB15-A65DD7D8137E}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{A10E754C-6C5C-47F2-BB15-A65DD7D8137E}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {D9C9B872-4034-4045-9836-1668F74D81DB}
24+
EndGlobalSection
25+
EndGlobal

0 commit comments

Comments
 (0)