Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Stephen Bonadies
- // COP3330-13
- // A program to solve a word search
- import java.io.File;
- import java.io.PrintStream;
- import java.util.Scanner;
- public class WordSearch {
- public static void main(String[] args) throws Exception{
- Scanner sc = new Scanner(new File("puzzle.txt"));
- // reading in rows and columns for the array
- int numRows = sc.nextInt();
- int numCols = sc.nextInt();
- //int [][] wordArray = new int [numRows][numCols];
- // looping over the array to find words
- for(int i = 0; i < numRows; i++){
- String getChar = new String(sc.next());
- for(int j = 0; j < numCols; j++){
- char [][] charArray = new char [numRows][numCols];
- char puzzle = getChar.charAt(j); // this will get all the characters in the array to find the word
- }
- }
- // reading in number of words to find in the array
- int numWords = sc.nextInt();
- for(int i = 0; i < numWords; i++){
- String getWord = new String(sc.next());
- String [] wordArray = new String [numWords];
- }
- // iterating over the array using the method wordCheck created
- for(int x = 0; x < numRows - 1; x++){
- for(int y = 0; y < numCols - 1; y++){
- // call the method
- }
- }
- sc.close();
- }
- // this method will be used to check for the words
- // posx, posy, posx2 and posy2 are used to get the x and y positions, diffx and diffy are to check the difference in positions
- private void wordCheck(char puzzle [][], String wordArray[], int numWords, int posx, int posy, int posx2, int posy2, int diffx, int diffy, PrintStream prints){
- for(int i = 0; i < numWords; i++){
- int wordLength = wordArray.length;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment