Trying to write it java first and then pseudo code

Assignment Help JAVA Programming
Reference no: EM13810449

A popular diversion in the United States, "word find" (or "word search") puzzles ask the player to find each of a given set of words in a square table filled with single letters. A word can read horizontally (left or right), vertically (up or down), or along a 45 degree diagonal (in any of the four directions) formed by consecutively adjacent cells of the table; it may wrap around the table's boundaries, but it must read in the same direction with no zigzagging. The same cell of the table may be used in different words, but, in a given word, the same cell may be used no more than once. Write a computer program for solving this puzzle.

Trying to write it java first and then pseudo code.

public class WordSearch {

private static ArrayList board = new ArrayList()

private static Scanner scanner

public static void readBoard() {

while (true) {

line = input next line

if (line equals NULL)

exit from loop

Delete all spaces in line, convert to Uppercase and add to board } }

public static void printBoard() {

rows = getRows();

for (row=0 to rows)

print board.get(row); }

public static int getRows() {

return the number of rows }

public static int getCols() {

return the number of columns }

public static void createScanner() {

try {

scanner = new Scanner(new java.io.File("WordSearchInput.txt")); }

catch (Exception e) {

exit from program } }

public static void processWords() {

while (scanner has a next word) {

word = scanner.next();

findWord(word); }

public static void findWord(String word) {

rows = get the number of rows

cols = get the number of columns

for (row=0 to rows)

for (col=0 to cols)

findWord(word,row,col); }

public static void findWord(String word, int row, int col) {

for (drow=-1 to 1)

for (dcol=-1 to 1)

findWord(word,row,col,drow,dcol); }

public static void findWord(String word, int row, int col, int drow, int dcol) {

rows = get the number of rows

cols = get the number of columns

for (offset=0 to word.length) {

targetRow = row + offset*drow;

targetCol = col + offset*dcol;

if ((targetRow is less than 0) OR

(targetRow is greater than equal to rows) OR

(targetCol is less than 0) OR

(targetCol is greater than equal to cols))

return

boardChar = board.get(targetRow).charAt(targetCol);

wordChar = word.charAt(offset);

if (boardChar not equal to wordChar)

// mismatch, so we're done

return }

print (word, row, col, drow, dcol); }

public static void main(String[] args) {

createScanner();

readBoard();

printBoard();

processWords(); } }

}

Reference no: EM13810449

Questions Cloud

Define the kent and kendall visions of intelligence : What are the most important differences between the Kent and Kendall visions of intelligence. Why are these differences so important and worth discussing. Which vision might be most applicable today and why
What is the variance of these returns : Five years ago, you purchased 600 shares of stock. The annual returns have been 7.2 percent, -19.4 percent, 3.8 percent, 14.2 percent, and 27.9 percent, respectively. What is the variance of these returns?
Use a spreadsheet to construct a pareto chart : The following data is collected from customer complaints about service problems at a hotel. Complaint types are coded A-G. Use a Spreadsheet to construct a Pareto chart for this data.
How should a manager motivate his or her staff members : An essay presents a well-argued discussion or response to a question using analysis and critique of relevant literature. It establishes a proposition or thesis and presents a point of view based on evidence. An essay is written in a logically stru..
Trying to write it java first and then pseudo code : A popular diversion in the United States, "word find" (or "word search") puzzles ask the player to find each of a given set of words in a square table filled with single letters. Trying to write it java first and then pseudo code
Determine before tax-costs of debt financing of bond : Use the information below to determine before tax-costs of debt financing of bond S:
Level of detail needed for a complete cost estimate : How will you reach the level of detail needed for a complete cost estimate? What items should you include in your cost estimate that are not explicitly present in the project schedule?
Define men and women handle disease differently : men and women handle disease differently
Genesis energy capital plan report : The Genesis Energy operations management team, nearing completion of its agreement with Sensible Essentials, was asked by senior management to present a capital plan for the operating expansion. The capital plan was not to be a wish list but an analy..

Reviews

Write a Review

JAVA Programming Questions & Answers

  Add a button that will read the text fields

Create a GUI with two text fields for inputting the dimensions of a rectangle. Identify these two text fields as Length and Width with labels. Add a button that will read the text fields and cause the GUI to display the area and perimeter of the r..

  Build a very straightforward and fully functional machine

Build a very straightforward and fully functional machine learning classifier with the K-Nearest Neighbor (KNN) algorithm. The KNN model will read a set of data specified by the user, decide the appropriate class of the new instance, and finally o..

  Write the definition of the class inventory

Write the definition of the class Inventory such that object of this class can store an item's id, name, number of pieces in stock, manufacturer's price, and selling price. The class should include constructors, setters, getters, and toString meth..

  Write programs that read a line of input

Write programs that read a line of input as a string and input

  Draw a picture with an appearance

You must use the given Rectangle and Oval classes to draw a picture with an appearance as close as possible.

  Enterprise java beans (ejb) in software development

Enterprise Java Beans (EJB) in software development, EJB technology, EJB application, Stateless Session Beans (SLSB), Stateful Session Beans (SFSB), Message Driven Bean (MDB), Entity Bean

  World data app

Prepare WorldDataApp project. It implements the NameIndex portion, including creating it in SetupProgram, and searching, viewing and updating it in UserApp program.

  How to link different classes forms

How to link different classes forms. When a person clicks on A, B, or C the program will go to the addEmployee form or Punch In/Out form in Java.

  Write a short java method to count the number of nodes

Write a short Java method to count the number of nodes in a circularly link list.

  Dijikstra for undirected graph using simple scheme with

dijikstra for undirected graph using simple scheme with array and fibonacci heap and compare the performanceresults

  Write a program to register students for a college students

write a program to register students for a college. students have names addresses and courses. implement the interface

  Illustrate the power of java inheritance and polymorphism

Illustrate the power of Java inheritance and polymorphism. Your response to this question is in multiple parts. You will submit your answers as specified at the end of this question.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd