Well, I'm making a couple assumptions here but here goes.
1.) I'll assume that these classes are setup to handle only 1 asset per depreciator class
2.) With that in mind, the class structure for Depreciator your instructor has outlined seems slightly flawed (too much recursion).
3.) No error handling has been built in to check to see if the depreciator has an asset object before you call the getDepreciationTable function, if an asset has not been set at this time, the program will throw a run-time exception
With all that in mind it should probably look something like this:
Code:
public String getDepreciationTable(String method) {
String returnString = "";
String returnValue = null;
NumberFormat nf = NumberFormat.getCurrencyInstance();
switch(method) {
case "SLD":
returnValue = nf.format(getSLD());
break;
case "SYD":
// this is where the run-time exception will occur if an asset hasn't been created
returnValue = nf.format(getSYD(getAsset().getYearPurchased()));
break;
case "DDB":
//assuming double basis variable is not private
returnValue = nf.format(getDDB(bookValueVariable);
break;
} // end switch
return ;// do your return statement here, outputting your html and returnValue
} // end function getDepreciationTable
Depending on how you actually compute those values (sorry I didn't take the time to read up on deprecation) you may need to encapsulate the switch statement in a for loop
Yes the formulas should be in the getSYD and getSLD, etc...
These functions (if you implement the code I wrote) should return raw double's which will then be formatted with commas and dollar signs using the nf (NumberFormat) object. To use this, you'll need to import java.text.NumberFormat if you haven't already.
Not sure where the book value variable should come from, the form probably. In which case, you'll need to do one of two things, add a new variable and a get/set method for it, that stores the bookValue, or pass a bookValue variable along with the method name in the getDepreciationTable function.
If it still doesn't make sense, I should be able to sit down and work the whole class out.
Don't worry about the ambiguity.
Happens all the time, it's only bad if you don't know how to express your problem fully even after someone asks you to that it becomes a problem.