So my goal is to build a word search here. The road block I have run into is how to save words, input from user, into an array. Then once I figure that out I need to try and arrange them in such a way so that they will fit into my array without screwing with one another. It does not have to be working exceedingly well I mean really it can be assumed that the users will not try to screw the program up. Ie one or two words and a fairly large table will be all the input. Here is the program as of now:
import java.util.Random; import java.util.Scanner; public class BuildWS { int r; int c; char[][] array; String query = " "; public BuildWS() { } public void build() { collectInfo(); print(); } public void collectInfo() { System.out.println("How many rows?"); Scanner in = new Scanner(System.in); r = in.nextInt(); System.out.println("How many columns?"); Scanner in1 = new Scanner(System.in); c = in.nextInt(); array = new char[r][c]; Random ran = new Random(); for (int i = 0; i < r; i++) { for (int j = 0; j < c; j++) { array[i][j] = (char)(ran.nextInt(26) + 'a'); } } Scanner in2 = new Scanner(System.in); while (!query.equals("end")) { System.out.println("Add a word to your search. Type end to quit"); query = in2.nextLine(); if (!query.equals("end")) { paste(query); } } } public void print() { for (int i = 0; i < array.length; i++) { for (int j = 0; j < array[i].length; j++) { System.out.print(array[i][j] + " "); } System.out.println(); } } public void paste(String inString) { System.out.println(inString);// Here is where I want to operate on the words. How do I save inString into the array as a string? } }