CSC 224

Winter 2003

Assignments

Software

To complete the assignments, you will need to use the Java 2 SDK (software development kit) to compile and run your programs.  This is installed on machines in student labs.  You may install it on your own machine from the CD that accompanies the textbook.  Alternatively, you can download the SDK from Sun.  To write your programs, you may use a text editor.  I suggest Textpad.  

Please see the instructions on downloading and installing the Java 2 SDK package.  My thanks to Steve Jost for providing this information.  

Coding rules

Please follow these syntax rules when writing your programs. Not doing so will cost points.

  1. Top comments: The top of every program must be a block of comments like this:
    //
    // CSC 224, section 501
    // Assignment 1
    // Programming exercise 16(a)
    //
    // John Rogers
    // jrogers@cs.depaul.edu
    // 
    
  2. Variable names: Variable names must be nouns or noun phrases and must be recognizable words.  They must begin with a lowercase letter and may not contain underscores nor (except in rare instances) digits.  If the name is made up of more than one word, the subsequent words must be capitalized.  Examples of valid names include: index, counter, scoresAverage, amountToPay; examples of invalid names include:INDEX, cnter, Index, scoresaverage, scores_average, amt2pay.  A name like index2 is acceptable as long as there is a variable named index1 in the same scope.
  3. Method names: Method names must be verb phrases, where the first word is a verb followed by an optional noun phrase.  They must begin with a lowercase letter and may not contain underscores or digits.  Subsequent words in the name must be capitalized.  Examples of valid names include: sort, computeAverage, makeChange, swapValues; examples of invalid names include: srt, computeaverage, mkChnge, valueSwap.
  4. Class names: Class names are almost always noun phrases with all words capitalized and no underscores.  Valid examples include: Student, VendingMachine, BankAccount; invalid examples include: student, vendingMachine, Bank_Account.  

Assignments

Assignment 1 (due Thursday, January 16th)

Complete exercises 16 and 24 from pp. 133-134 in the text.  Submit a single zip file with all four programs.  Make sure that the name each file and the name of the class it contains are the same. 

Assignment 2 (due Thursday, January 23rd)

Write the definition of a Warehouse class as specified in exercises 16, 20, and 21 on p. 247.  Also write a program to test each of the methods in the class.  

Write the definition of a Fraction class as called for in exercise 23 on p. 248.  Add to it a method called toString that converts a fraction to a String.  Write the methods so that the fraction is always stored in lowest terms.  Use FractionTest.java to test your Fraction objects.

Submit a single zip file with three files: Warehouse.java, TestWarehouse.java, and Fraction.java.

Assignment 3 (due Thursday, January 30th)

Write an applet to draw a chessboard, which is an 8-by-8 collection of squares whose colors alternate between black and red. 

Assignment 4 (due Thursday, February 13th)

Write the applet described in problem 24 on p. 338 of the textbook. 

Write the applet described in problem 21 on p. 337 of the textbook.  I will have more to say about this one in class.

Assignment 5 (due Tuesday, February 25th)

Write a program that reads a list of integers from a file and displays the following statistics in a dialog box:

The program should try to get the name of the file to open from the command line.   If it can't do this, it should prompt the user for the file name.  If it is unable to open the file, it should display an error message in a dialog box and exit.   Otherwise, it should proceed with the rest of the calculations. 

The program should be structured, which means that such operations as opening the file and computing the average should be done in methods separate from main.

Assignment 6 (due Tuesday, March 12th)

For this assignment, continue with the implementation of a Matrix class hierarchy.  Please define a Matrix class and an IntMatrix subclass.  As discussed in class, include instance variables that keep track of the dimensions of a matrix and instance variables for storing the matrix values.  Provide at least the following methods:

There are a variety of exceptions that can occur and that your code must detect.  For example, trying to create a matrix with a non-positive dimension or trying to access an entry not in the matrix are two situations where an exception should be thrown. 

Write a program to test your class.  I have posted an example test program

Submit your files in a zip archive.