|
home—info—lects—labs—exams—hws
textbook—tutor/PIs—java.lang docs—java.util docs
This is for ITEC120's hw04—metamorphosis.
Do not help students with code if they have not written their test cases. (A test class should create an object (or two), call methods, and print out the expected results).
Experience shows that often students will come asking for help with their code, and after 15-20minutes it becomes clear the reason they can't write the code is that they are not exactly sure what the method is supposed to do. Writing test cases forces one to figure this out (as well as figure out the exact meaning of the signatures/parameters, as well as providing a way to check the code once they've finished).
The primary class should contain no calls to println. Only the test-class should print to the screen.
Rather than use casting (which doesn't look like a method-call at all, even though it is), I recommend using Math.round(double) to convert doubles to ints.
(We have not talked about casting syntax in class, although it does happen to be in the reading assigned from the book.)
Alas, Math.round(double) returns a long integer, instead of a regular int. If you get the error “possible loss of precision”, that's the problem. The hw suggests just using long throughout the entire program, instead of int.
(We have not talked about long (or float) in class, although it does happen to be in the reading assigned from the book.)
home—info—lects—labs—exams—hws
textbook—tutor/PIs—java.lang docs—java.util docs
©2009, Ian Barland, Radford University Last modified 2009.Feb.19 (Thu) |
Please mail any suggestions (incl. typos, broken links) to ibarlandradford.edu |