Lab 2

Due Friday, 2/6 - 5:00PM

  1. Ex5.17 - Write a for loop to print the multiples of 3 from 300 down to 3.
  2. Implement a method that takes as input a reference to a sorted array of String objects, an integer representing the number of valid String objects contained in the array, and a new String object to be inserted into the array.  The method will insert the new String object at the appropriate location and resize the array if necessary.  The method returns a reference to the new array.  The signature of the method follows:
    • public String[] insertSorted(String[] stringlist, int numstrings, String newstring);
  3. Implement a class Square.  A Square represents the information about a single square of a Sudoku board.  A Square has the following data members, and get/set methods for each data member:
    1. original - a variable of type boolean to indicate whether the value was set in the original puzzle
    2. set - a variable of type boolean to indicate whether the value has been set by the user, or was set in the original puzzle
    3. value - a variable of type int to indicate the value stored in the square.  if the square has not been set, the value will be 0.
  4. Implement a class Board that has a 9x9 array of Squares as its data member.  Implement a method checkRows in the Board class.  checkRows returns true if every row in the array contains a square with each value 1-9.  For testing, statically set the values stored in each Square of the array.  The signature of the checkRows method is as follows:
    • public boolean checkRows();
  5. Implement a program that provides search-and-replace functionality.  Allow the user to specify a search term, a replace term, and a file name.  Open the file, replace all instances of the search term with the replace term and save the result to a new file.  You may choose the name of the new file.
Submission Instructions