Today we'll work with a partner; before leaving, check off which of the problems below you were able to finish.
Get the code into BlueJ (by pasting, or saving&re-opening the file). Look at how the comments have been formatted, for each method and named constant. Namely,
Note how the documentation is automatically produced by BlueJ,
using these specially
formatted “javadoc” comments.
(This isn't unique to BlueJ; it is a standard tool used in Java,
and this particular format is catching on to other languages as well.)
For the rest of the semester, we will also use this format.
What does implementation vs interface mean? Take a gander at the interface for the Math class. When using Math.floor(·) or Math.PI, do you get to see the implementation, ever? No. This web page specifying the interface is all you are allowed to see. Likewise, when other programmers are using your code, they might only see your documentation, and nothing else. Please make sure the interface (a) gives others the information they need so that they can do their job, and (b) does not mention details of how you implement or calculate some result, since you might change how you calculate an answer (like the tax of an item after the legislature passes new laws) but the interface shouldn't change (your function still calculates the tax, and that's all others need to know).
/** * Give a textual description of this PizzaServer. The text will * mention that that it describes a PizzaServer, and will include * the value of its field(s). * * @return A string representation of this PizzaServer. * A sample return value might be "[PizzaServer -- salary: $4.23]" * but with the salary field reported appropriately. */ String asString() { return "...replace me..."; /* Note: If we ever add more fields to this class, * we should come back and update asString to print those out too. */ } |
PizzaServer jo = new PizzaServer(); jo.setSalary( 12.34 ); PizzaServer moe = jo.makeClone(); moe.getSalary() /* Should be 12.34. */ |
©2006, Ian Barland, Radford University Last modified 2006.Sep.20 (Wed) |
Please mail any suggestions (incl. typos, broken links) to ibarlandradford.edu |