Commit ef40e7ba authored by trh010's avatar trh010
Browse files

working on the structure of the program

parent 56962a8c
......@@ -3,11 +3,15 @@ package main;
import java.util.ArrayList;
public class AdjacencyList {
private ArrayList<ArrayList<String>> adjList;
public AdjacencyList(){
adjList = new ArrayList<ArrayList<String>>();
}
private ArrayList<ArrayList<String>> adjList;
public AdjacencyList() {
adjList = new ArrayList<ArrayList<String>>();
}
public void addNode(String newWord) {
}
}
......@@ -6,17 +6,28 @@ import java.util.Scanner;
public class Main {
/** Adjacency list containing the graph of word connections */
AdjacencyList adjList;
/** Default Constructor */
public Main() {
adjList = new AdjacencyList();
}
/**
* Creates a graph from a file containing a list of words. The graph is
* implemented using an adjacency list.
*
* @param path
* the input file
*/
public void createGraph(String path) {
File file = new File(path);
try {
Scanner in = new Scanner(file);
System.out.println(in.next());
while (in.hasNext()) {
adjList.addNode(in.next());
}
in.close();
} catch (FileNotFoundException e) {
System.err.println("Error in opening the file: " + path
......@@ -24,10 +35,17 @@ public class Main {
}
}
/**
* Main method. Runs the program from the given input file
*
* @param args
* the input file path
*/
public static void main(String[] args) {
try {
Main main = new Main();
main.createGraph(args[0]);
} catch (Exception e) {
System.err.println("Error! - " + e.toString());
}
......
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