Assignment 2, CSC108S 2002

Due: Friday January 25, 12 noon --- no late assignments can be accepted.

Modeling divers

You will build a simple class to model a SCUBA diver, so that the dive master can keep track of their vital statistics. The properties of each diver are:

If the diver is wet, then all the attributes are relevant. If the diver is dry, then their depth is 0, and their tank capacity is irrelevant (the values of this attribute can be ignored). If the diver is bent, then their tank capacity is irrelevant, but their depth is kept on record, to help medical staff treat them.

What you need to do

You'll complete the class Diver, which we've begun. We've also provided a second class, TestDiver that demonstrates how the methods in Diver are called. Do not make any changes to TestDiver, nor any of the methods or variables in Diver that we have provided. This intentionally constrains your design choices.

Steps

  1. Download files TestDiver.java and Diver.java, and read them carefully. The class TestDiver contains a main method that makes use of class Diver.
  2. Create a CodeWarrior project Assignment2 and include the two .java files. Be sure to set the CodeWarrior Target Settings so that TestDiver is the main class.
  3. The program won't compile yet, because you have more work to do on Diver.java. Finish it. We have provided the provided method comments for some methods you need to write. It's like a jigsaw puzzle: you can figure out what those five methods should be called and what their parameters are by looking at what happens in TestDiver and by carefully reading the method comments. You also need to figure out the last instance variable (there's a comment for that too).
  4. Following the direction from the web site, submit your corrected Diver.java file electronically for marking. You don't need to submit TestDiver.java, since it hasn't been changed. You also don't need to submit any project files or .class files. Reread the rules for assignment submission to be certain you've followed them.

Danny Heap
Last modified: Wed Jan 16 14:33:30 EST 2002