Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
trh010
cs311_final_project
Commits
ef40e7ba
Commit
ef40e7ba
authored
Apr 15, 2014
by
trh010
Browse files
working on the structure of the program
parent
56962a8c
Changes
2
Hide whitespace changes
Inline
Side-by-side
CS311_final_project/src/main/AdjacencyList.java
View file @
ef40e7ba
...
...
@@ -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
)
{
}
}
CS311_final_project/src/main/Main.java
View file @
ef40e7ba
...
...
@@ -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
());
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment