CS111 Programming Assignment 1

Instructor: Trish Cornez


  Word of Advice -
  1. Programs will be evaluated on functionality and code quality.

  2. Debug and comment all source code.

  3. Please list your name and date at the top of each .java file.

  4. Execute thorough test runs for your programs to assess functionality.

  5. Assigned work is to be an individual endeavor.
    Group or shared assignments will not be accepted.
    Remember that discussion about assignments with others should be of a general nature.




Program 1: Arrays and Strings
Word Scramble is a puzzle game in which the app displays a scrambled version of a word where the letters are in random order.
The player has to guess the word to win the game.
If the player is stuck, he can ask for a hint.
An execution of the game is shown below.




Use the following guidelines:
  1. Use methods to organize your code. Points will be given for quality of code.
  2. Declare and initialize a dictionary (two-dimensional String array of words and corresponding hints).
  3. Pick a word from the dictionary.
  4. Scramble the word. One possibility is to convert the word to a char array (word.toCharArray(). The letters of the array can then be shuffled by selecting two random indices and swapping the characters at those positions. Multiple swaps can be performed many times.
  5. Use a loop to prompt the user for the correct word until he either guesses the word or asks to quit. The user should be allowed to request a hint.


Program 2: Two-dimensional ArrayList
Write and test a function that rotates a two-dimensional square "matrix" (any size) of integers.
Use either an array or ArrayList to solve this problem. When using an array, test by creating a static 2D array. If you are using an ArrayList, prompt the user for the number of rows and then for each ArrayList cell value.

Initial matrix:

11 22 33
44 55 66
77 88 99

Matrix rotated 90 degrees:

77 44 11
88 55 22
99 66 33