-
Notifications
You must be signed in to change notification settings - Fork 0
/
WordLinks.java
33 lines (32 loc) · 945 Bytes
/
WordLinks.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import java.util.ArrayList;
import java.util.Scanner;
public class WordLinks {
public static void main(String[] args) throws Exception
{
LinkChecker linkCheck = new LinkChecker();
Scanner inputScanner = new Scanner(System.in);
boolean wordChainInputted = false;
while(!wordChainInputted )
{
System.out.println("Enter a comma separated list of words (or an empty list to quit):");
ArrayList<String> wordList = new ArrayList<String> ();
if( inputScanner.hasNextLine())
{
wordList = linkCheck.readWordList(inputScanner.nextLine());
if(wordList.size() ==0 )
{
wordChainInputted = true;
}
else if(linkCheck.isWordChain(wordList))
{
System.out.println("Valid chain of words from Lewis Carroll's word-links game.");
}
else
{
System.out.println("Not a valid chain of words from Lewis Carroll's word-links game.");
}
}
}
inputScanner.close();
}
}