CS100J Spring 2004
Project 2
Due Thursday 2/19 at 3pm

0. Objective

Completing all tasks in this assignment will help you learn about: First skim, and then carefully read the entire assignment before starting any tasks! Write (type) your answers to Questions 1 and 2 in one plain text file called q1q2.txt. You will customize, i.e., extend, class JFrame in questions 3 and 4. You must use the identifiers (variable names, class names, etc.) exactly as we specify, including capitalization. Use good programming style and observe the style guidelines that are given in the Project 1 Grading Guide (to be posted 2/9).

1. Which type?

consider the following set of variables for a Java class that describes a building. Of the types and classes that we have discussed in lecture, which one would you pick for each variable? Copy (the incomplete) class Building below into file q1q2.txt and replace the blanks with your answers.

    /** A generic building */
    public class Building {
      ________ floorSpace;      //total floor space in square feet
      ________ floorCount;      //number of floors
      ________ address;         //address of the building
      ________ owner;           //owner of the building
      ________ ownerOccupied;   //is the owner an occupant of the building?
      ________ phoneLineCount;  //number of connected telephone lines
    }

2. Java API

Read Section 1.3.2 of the text and refer to http://java.sun.com/j2se/1.4.2/docs/api/ to answer the following questions on the Java API. Write your answers in the plain text file q1q2.txt. Be sure to use line breaks to limit the length of each line.

  1. What does API stand for? Briefly explain what the Java API is.
  2. Take a look at the Math class. What are the two fields?
  3. Take a look at the System class. Which method do you use to get the current system time?
  4. Take a look at the String class. What does method trim do?
  5. Take a look at the DecimalFormat class. How do the pattern characters 0 and # differ?
  6. Take a look at the JFrame class. How many constructors are there?
  7. Take a look at the Date class in package Java.util. Be careful, there are two different classes called Date in two different packages. What are the possible values for representing a month?
Note:   You do not need to read the API documentation in detail to answer the above questions. The objective of this exercise is for you to learn about the API and to learn how to find detailed specifications should you have the need in the future. In order to answer the above questions, you only need to skim through the first pages of the description for each class.

3. Double visionDouble vision

Complete Exercise E6 on page 46 of the text. Use file name DoubleVisionFrame.java. All fields must be private and all methods should be public.

4. Funny eyes or funny face?

Complete Exercises E9, E10, and E11 on pages 47 and 48 of the text. Use file name FaceFrame.java. All fields must be private and all methods should be public.

Additional specification: Choose the colors for drawing the eyes according to the following rules.

5. Submitting Your Work

Submit all three files on-line using CMS (Course Management System) before the project deadline. See the CMS link on the web page for instructions on using CMS.