CSE 8B: Introduction to Computer Science: Java (Winter, 2006)

Home | Syllabus | Schedule | Exams | Programming Assignments

Programming Assignment 2

Due Monday, January 23 at 11:59 PM.

In this assignment, you'll be working with both rational and complex numbers. The former, you learned about in Algebra, the latter, you likely learned about in Algebra II/Trigonometry.

However, since you may have forgotten, I've provided a brief description, and some links:

Test-Driven Development

In this exercise, you are to use test-driven development in the manner described in class. You'll write a test, verify the test fails, then write enough code to get the test to pass. At any point where you've got all tests passing, you can refactor to clean up your implementation code or your test code.

The example from class is available as a QuickTime movie.

The documentation for junit is also available.

Requirements

I've provide a Rational class that implements rational numbers. The TestRational unit test will give you a good example on using the class. Here are the basics: There is a webpage with documentation for the Rational class.

Requirements

You need to write a Complex class that follows documentation I've written. The method signatures should exactly match those in the documentation. The documentation also includes a full description of what each method should do.

Provided files

Copy Rational.class and TestRational.java from the P2 directory in the public directory (~/../public/P2/*).

Turnin

Create a directory on ieng6 with the following files: To turn in your assignment, cd to that directory and run the command
  bundleP2
and carefully follow the dialog. If it is before the due deadline and all necessary assignment files are present, this will turn in your solution files. You can run bundleP2 more than once if you want; only the last one will count. Subsequent assignments will be turned in with similar commands, bundleP2, bundleP3 and so on.

Grading

The assignment is worth 20 points: As always, an additional 5% (1 point) is available if you turn the assignment in at least 24 hours early.