One approach: When you are stuck, (or, as many will argue, all the time), you should Start with the Test Code. Below I'm using skeletal JUnit3 for that, not sure what you are using in your class. Your imaginary thought process is in italics.
Well, I'm going to have to a test a method which computes the area of a circle.
public void testAreaOfCircle() {
double areaCalculated = Well, I need a function here...
assertEquals(TRUE_AREA, areaCalculated);
}
o.k., next step, let's fill in the function and the test
public void testAreaOfCircle() {
double r = 2.3; // some arbitrary positive number
double areaCalculated = MyClass.areaOfCircle(r); // let's make the method static for now...
assertEquals(r*r*Math.PI, areaCalculated);
}
Hmm, what should happen if r is < 0? I'll ask the teacher what he wants and hope I get extra credit! Add that to your test code...
(minor note - assertEquals is not robust for floating point math, worry about that later...)
Finally, you should create a skeletal method to implement the algorithm, and work on it till the test succeeds.
public static double areaOfCircle(double r) {
if (r < 0)
throw new IllegalArgumentException(); // or whatever...
double area = WHAT MATH DO YOU NEED HERE?
return area;
}
Follow a similar process for your other methods.