The goals of this assignment are to:
You need to write a program that will let you play a nonsense word find game. Your program will generate a 2-dimensional array of characters, display the array to the user and ask the user to enter "words" to find in the array.
The reason that "words" is in quotes is because the words are really just sequences of letters and aren't necessarily words that belong to any natural (i.e., spoken) language. The 2-dimensional array that your program generates will be done randomly, so there is no guarantee that it will actually contain any real words from any language.
Your program will do the following (the overall logic of your code -- i.e., following the steps outlined below -- is worth 0.6 points):
Keyboardclass, as below; 0.5 points) and convert the input to an int (0.2 points)
enter word to find (9 to quit):(0.1 points)
Keyboardclass, as below)
findInRow()method, as below; 0.8 points)
findInColumn()method, as below; 0.8 points)
replaceInRow(), 0.8 points; or
replaceInColumn(), 0.8 points; as below)
word not found. (0.1 points)
Your program will consist of 3 classes. You can click on the links below for skeletons of the first two classes. You must write the third from scratch.
Keyboardclass. As instructed by the comments in the code, write the following method:
public static String readline()
Squareclass. As instructed by the comments in the code, declare any necessary global constants and/or variables, write a constructor and the following methods:
public Square( int size )
public void init()
public void print()
public int findInRow( String s )
public int findInColumn( String s )
public int replaceInRow( int i,String s )
public int replaceInColumn( int j,String s )
hw4<yourCUNIXusername>.javacontaining a single main method that controls the program as it runs through the steps described in the specification section (above).
Below is a sample run. The unix command line is highlighted in bold font.
unix$ java hw4eis2003 enter size for square: 10 clssqrdets wizibsyphg hrmagwpuge evuqmiisah iyvhvlfkkx ipzwehgdpl knjalmpjmc jkyniyzste ffkirnhfvg fyrwecsrzg enter word to find (9 to quit): lire clssqrdets wizibsyphg hrmagwpuge evuqmiisah iyvhvlfkkx ipzwehgdpl knja.mpjmc jkyn.yzste ffki.nhfvg fyrw.csrzg enter word to find (9 to quit): IS clssqrdets wizibsyphg hrmagwpuge evuqmi..ah iyvhvlfkkx ipzwehgdpl knja.mpjmc jkyn.yzste ffki.nhfvg fyrw.csrzg enter word to find (9 to quit): sssss word not found enter word to find (9 to quit): 9
Your source code (i.e., your
.java file) but be
neat and clearly commented.
You must have a header comment and you should comment the end of each
block (i.e., each
You need to comment each method that you write within in each class.
Follow the submission instructions carefully!!! If you don't, human intervention will be required to fix your mistakes, and you will lose 0.5 points.
This assignment is worth 7 points (out of 100 for the semester). Distribution of points is: