Question: Assume that a BodyWeight class contains only one setWeight methoda two-parameter version with the parameters double weight and String units. Write two constructors for the
Assume that a BodyWeight class contains only one setWeight method—a two-parameter version with the parameters double weight and String units. Write two constructors for the BodyWeight class, one with one argument (double weight), and the other with two arguments (double weight and String units). For the one-argument constructor, use the default of “kg” for units. Avoid code redundancy. That is, have the one-parameter constructor call the two-parameter constructor, and have the two-parameter constructor call the two-parameter setWeight method.
Step by Step Solution
3.33 Rating (165 Votes )
There are 3 Steps involved in it
Sure I can help with that Below is the Java code for the BodyWeight class with your specified constr... View full answer
Get step-by-step solutions from verified subject matter experts
