{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

WordRDjava - System.out.print(grid[l[w...

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

View Full Document Right Arrow Icon
import java.util.Scanner; import java.io.*; public class WordRDjava { private char [][] grid; private int length; private int width; private String dimensionsArray[]; private String gridDimensions; private boolean containsChar = false; public void Word(Scanner input){ gridDimensions = input.nextLine(); dimensionsArray = gridDimensions.split(" "); length = Integer.parseInt(dimensionsArray[0]); width = Integer.parseInt(dimensionsArray[1]); System.out.println(length + " " + width); } public void read(Scanner input) { grid = new char [length][width]; for(int l = 0; l < length; l++){ String line = input.nextLine(); line = line.toLowerCase(); for(int w = 0; w < width; w++){ grid [l][w] = line.charAt(w); } } } public void print() { for(int l = 0; l < length; l++){ System.out.println(); for(int w = 0; w < width; w++){
Background image of page 1

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

View Full Document Right Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: System.out.print(grid [l][w]); System.out.print(" "); } } } public boolean checkHorizontal(String guess) { for(int l = 0; l < length; l++){ String line = String.valueOf(grid[l]); String subLine = ""; for (int g = 0; g < guess.length(); g++){ for(int w = 0; w < width; w++){ if(guess.charAt(g) == grid[l][w]){ if(w + 1 >= guess.length()){ subLine = line.substring(line.indexOf(line.charAt(w)), guess.length()); System.out.println(subLine); if(guess.equals(subLine)){ System.out.println("Correct!"); } } } } } } return containsChar; } public boolean checkVertical(String guess, Scanner input) { return false; } public boolean checkDiagonal(String guess, Scanner input) { return false; } public String toString(){ return ""; } }...
View Full Document

{[ snackBarMessage ]}

Page1 / 2

WordRDjava - System.out.print(grid[l[w...

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

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