Lab 1

Due 9:40AM September 8, 2008

  1. PP 3.3 - Write an application that creates and prints a random phone number of the form XXX-XXX-XXXX. Include the dashes in the output. Do not let the first three digits contain an 8 or 9 (but don't be more restrictive than that), and make sure that the second set of three digits is not greater than 742. Hint: Think through the easiest way to construct the phone number. Each digit does not have to be determined separately.
  2. PP 4.6 - Design and implement a class called Bulb that represents a light bulb that can be turned on and off. Create a driver class called Lights whose main method instantiates and turns on some Bulb objects.
  3. Implement a method that takes as input 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 will return the resulting String[]. The signature of the method follows:
  4. public String[] insertSorted(String[] stringlist, int numstrings, String newstring);
  5. Implement the method described by the following signature. The method takes as input a 3x3 array of chars and a single char to represent the player. The method returns true if the character player appears three times in a row either horizontally, vertically, or diagonally.
  6. public boolean containsWin(char[][] board, char player);

Sami Rollins