Initial Commit

This commit is contained in:
Eoghan Conlon 2024-12-01 23:55:06 +00:00
commit e786ef2c55
3 changed files with 96 additions and 0 deletions

33
.gitignore vendored Normal file
View file

@ -0,0 +1,33 @@
### IntelliJ IDEA ###
out/
!**/src/main/**/out/
!**/src/test/**/out/
.idea/
### Eclipse ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
### VS Code ###
.vscode/
### Mac OS ###
.DS_Store
### AoC ###
in/

11
AoC_2024_java.iml Normal file
View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

52
src/Input.java Normal file
View file

@ -0,0 +1,52 @@
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.stream.Stream;
/**
* @author Eoghan Conlon
* This class is a base class for my Advent of Code in Java, it will be extended by the full projects.
*/
public class Input {
/// String arrays generated from the files
private ArrayList<String> sample_input;
private ArrayList<String> actual_input;
/**
*
* @param filePath Path to the folder where the files for the elevent days are located
* @return Exit Code - (0 if successful, non-zreo if fail)
*/
protected int init(String filePath) throws IOException {
// Adding the sample txt file and input txt files to the file path
Path samplePath = Path.of(filePath + "/sample.txt");
Path actualPath = Path.of(filePath + "/input.txt");
this.sample_input = new ArrayList<>();
this.actual_input = new ArrayList<>();
// Opening the files
try(Stream<String> lines = Files.lines(samplePath)){
lines.forEach(s -> sample_input.add(s));
} catch (IOException e) {
return 1;
}
try(Stream<String> lines = Files.lines(actualPath)){
lines.forEach(s -> actual_input.add(s));
} catch (IOException e) {
return 1;
}
return 0;
}
protected ArrayList<String> getSample_input(){
return sample_input;
}
protected ArrayList<String> getInput(){
return actual_input;
}
}