Word - import java.util.Scanner; import java.io.*; public...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: import java.util.Scanner; import java.io.*; public class Word { private char grid; private int length; private int width; private String dimensionsArray; private String gridDimensions; private boolean containsChar = false; /** This takes the dimensions of the grid. @param gridDimensions: takes nextLine from input. @param dimensinosArray: splits nextLine from input from a space. @param length: length of grid. @param width: width of grid. */ public Word(Scanner input){ gridDimensions = input.nextLine(); dimensionsArray = gridDimensions.split(" "); length = Integer.parseInt(dimensionsArray[0]); width = Integer.parseInt(dimensionsArray[1]); System.out.println(length + " " + width); } /** This reads the dimensions of the grid. @param grid: dimensions of the grid. @param line: the nextLine of the grid, in lowercase letters. */ public void read(Scanner input) { grid = new char [length][width]; for(int l = 0; l < length; l++){ // length String line = input.nextLine(); line = line.toLowerCase(); for(int w = 0; w < width; w++){ // width grid [l][w] = line.charAt(w); // takes character at specific position } } } /** This prints the dimensions of the grid. @param grid: dimensions of the grid for the values of l and w repsectively. */ public void print() { for(int l = 0; l < length; l++){ System.out.println(); for(int w = 0; w < width; w++){ System.out.print(grid [l][w]); System.out.print(" "); } } } /** This checks to see if a word was contained in any search methods, and...
View Full Document

Page1 / 4

Word - import java.util.Scanner; import java.io.*; public...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online