Create initial classes
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
package com.mattrixwv.adventOfCode24;
|
||||
|
||||
|
||||
import java.security.InvalidParameterException;
|
||||
import java.util.List;
|
||||
import java.util.Scanner;
|
||||
import java.util.StringJoiner;
|
||||
|
||||
import com.mattrixwv.adventOfCode24.days.Problem;
|
||||
|
||||
|
||||
public class ProblemSelector{
|
||||
private static final Scanner input = new Scanner(System.in);
|
||||
//Holds the valid problem numbers
|
||||
protected static final List<Integer> PROBLEM_NUMBERS = List.of(0);
|
||||
|
||||
|
||||
private ProblemSelector(){
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
|
||||
|
||||
//Returns the problem corresponding to the given problem number
|
||||
public static Problem getProblem(Integer dayNumber){
|
||||
Problem day = null;
|
||||
switch(dayNumber){
|
||||
default: throw new InvalidParameterException();
|
||||
}
|
||||
//return day;
|
||||
}
|
||||
|
||||
//Print the description of a problem
|
||||
public static void printDescription(Integer problemNumber){
|
||||
//Get the problem
|
||||
Problem day = getProblem(problemNumber);
|
||||
//Print the problem's description
|
||||
System.out.println(day.getDescription());
|
||||
}
|
||||
|
||||
//Solve a problem
|
||||
public static void solveProblem(Integer problemNumber){
|
||||
//Get the problem
|
||||
Problem problem = getProblem(problemNumber);
|
||||
System.out.println("\n\n\n");
|
||||
//Print the problem description
|
||||
System.out.println(problem.getDescription());
|
||||
//Solve the problem
|
||||
problem.runSolution();
|
||||
//Print the results
|
||||
System.out.println(problem.getResult());
|
||||
System.out.println("\n\n\n");
|
||||
}
|
||||
|
||||
//Get a valid problem number from a user
|
||||
public static Integer getProblemNumber(){
|
||||
Integer problemNumber = 0;
|
||||
System.out.print("Enter a problem number: ");
|
||||
problemNumber = input.nextInt();
|
||||
while(!PROBLEM_NUMBERS.contains(problemNumber)){
|
||||
System.out.print("That is an invalid problem number!\n Enter a problem number: ");
|
||||
problemNumber = input.nextInt();
|
||||
}
|
||||
return problemNumber;
|
||||
}
|
||||
|
||||
//List all valid problem numbers
|
||||
public static void listProblems(){
|
||||
StringJoiner joiner = new StringJoiner(", ");
|
||||
for(Integer num : PROBLEM_NUMBERS){
|
||||
joiner.add(num.toString());
|
||||
}
|
||||
System.out.println(joiner.toString());
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user