CS 1054 Introduction to Programming in Java (Spring 2008)

Project 3: Printing Letters

Instructions

For this project you will write a bunch of classes that print the letters E, H, O, P, S, and T in varying sizes using asterisks, spaces, and new lines. You will also write a program that uses these classes to interactively print these letters through console input and output.
  1. Create the following Java classes: Each of these classes should have a toString() method that returns a String. The string returned should consist of asterisks, newlines, and spaces (as necessary). Each of these classes should also have a two-parameter constructor indicating the height and the width of the letter ( height first, then width ). The height of a letter should be at least 5, and the width of a letter should be at least 4; if a parameter is supplied to the constructor that is below the minimum, set the dimension to the corresponding minimum. For the letters E, H, P, and S, if the height is even, the middle horizontal line should be above the median. For example, if the height is 6 and the width is 5, print these letters as follows:
    *****   *   *   *****   *****
    *       *   *   *   *   *
    *****   *****   *****   *****
    *       *   *   *           *
    *       *   *   *           *
    *****   *   *   *       *****
    
    For the letter T, if the width is even, the middle vertical line should be to the right of the median. For example, if the width is 6 and the height is 5, print the T as follows:
    ******
       *
       *
       *
       *
    
  2. Test your classes against this tester program (Create a LettersTester class within BlueJ and cut and paste the code in the link). Upon execution of the program, the program's output should match this output . (Make sure to select "Unlimited buffering" from the BlueJ terminal window, so that all output appears.)
  3. Create a LettersConsole class that repeatedly asks the user which letter to print including dimensions (height and width), and then proceeds with printing the letter as specified. Refer to Lab 7 for an example of this program.
  4. Submission: Zip all java programs and submit through http://web-cat.cs.vt.edu as you did before. This project is due on Wednesday, April 9 (11:59pm), but webcat will be accepting submissions as early as April 2. Your grade will depend on the correctness of your letter classes and the console program and compliance with coding style guidelines as indicated in Commenting .