Advertisement
Guest User

Untitled

a guest
Oct 10th, 2013
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.26 KB | None | 0 0
  1. package projecta;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.FileReader;
  5. import java.io.IOException;
  6. import java.util.ArrayList;
  7. import java.util.Arrays;
  8. import java.util.List;
  9.  
  10. /**
  11.  *
  12.  * @author Sameer Anand
  13.  *
  14.  */
  15.  
  16. public class Crossword {
  17.    
  18.     // Number of Words in Dictionary
  19.     // List of Words, Separated by Spaces
  20.     // The Number of Answers To Guess
  21.     // A Series of Space-Separated Characters With Letter or Underscore
  22.    
  23.     public static int numberOfDictionaryWords;
  24.    
  25.     public static String[] dictionaryWords;
  26.    
  27.     public static int numberOfAnswers;
  28.    
  29.     public static List<String> answers = new ArrayList();
  30.    
  31.    
  32.     public static void main(String[] args) throws IOException {
  33.        
  34.         BufferedReader input = new BufferedReader(new FileReader("src/ProjectA/input.txt"));
  35.        
  36.         Crossword crossword = new Crossword(input);
  37.        
  38.         /*
  39.        
  40.         System.out.println(crossword.getNumberOfWords());       // Print Number of Words
  41.        
  42.         System.out.println(crossword.getDictionaryWords());     // Print Dictionary Words
  43.        
  44.         System.out.println(crossword.getNumberOfAnswers());     // Print Number of Answers
  45.        
  46.         System.out.println(crossword.getAnswers());             // Print Answers
  47.        
  48.         */
  49.        
  50.         // OUTPUT
  51.        
  52.         for (int i = 0; i < crossword.getNumberOfAnswers(); i++) {
  53.            
  54.             crossword.numberOfFittedWords(dictionaryWords, answers.get(i));
  55.            
  56.         }
  57.        
  58.     }
  59.      
  60.     public Crossword(BufferedReader input) throws IOException {
  61.        
  62.        
  63.         // First Line = Number of Dictionary Words
  64.        
  65.         numberOfDictionaryWords = Integer.parseInt(input.readLine());
  66.        
  67.        
  68.         // Second Line = Words in Dictionary Separated by Spaces
  69.        
  70.         dictionaryWords = input.readLine().split(" ", numberOfDictionaryWords);
  71.        
  72.        
  73.         // Third Line = Number of Answers
  74.        
  75.         numberOfAnswers = Integer.parseInt(input.readLine());
  76.        
  77.        
  78.         // x Lines = Answers
  79.        
  80.         int lines = numberOfAnswers;
  81.        
  82.         for (int i = 0; i < lines; i ++) {
  83.            
  84.             answers.add(input.readLine());
  85.            
  86.         }
  87.        
  88.     }
  89.    
  90.     public int getNumberOfWords() {
  91.        
  92.         // Returns Number of Dictionary Words (First Line)
  93.    
  94.         return numberOfDictionaryWords;
  95.    
  96.     }
  97.    
  98.     public String getDictionaryWords() {
  99.        
  100.         // Returns List of Dictionary Words In a String (Second Line)
  101.        
  102.         return Arrays.toString(dictionaryWords);
  103.        
  104.     }
  105.    
  106.     public int getNumberOfAnswers() {
  107.        
  108.         // Returns Number of Answers (Third Line)
  109.        
  110.         return numberOfAnswers;
  111.        
  112.     }
  113.    
  114.     public List<String> getAnswers() {
  115.        
  116.         // Returns All of The Read In Answers In A List / Array
  117.        
  118.         return answers;
  119.        
  120.     }
  121.    
  122.     public int numberOfFittedWords(String[] dictionary, String answer) {
  123.        
  124.         System.out.println(dictionary);
  125.        
  126.         System.out.println(answer);
  127.        
  128.         return 0;
  129.        
  130.     }
  131.    
  132. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement