reset password
Author Message
mavanes2
Posts: 4
Posted 11:50 Jan 28, 2015 |

I understand the program is supposed to be able to calculate negative values, but what if the values passed to the Weight object were something like Weight( 1,  -3) or vice-versa? Would it be 0 pound and 13 ounces, 1 pound and -3 ounces or an error?

303496263
Posts: 68
Posted 11:52 Jan 28, 2015 |

You should not allow the user to assign negative values to the weight. You can easily handle that in your constructor setters.

 

Last edited by 303496263 at 14:06 Jan 28, 2015.
jpascua
Posts: 197
Posted 13:33 Jan 28, 2015 |

If the user cannot assign negative values to the weight, then the subtraction operator won't work since it returns new weight object (taking in negative parameters after the subtraction).

raywu64
Posts: 44
Posted 13:46 Jan 28, 2015 |

I don't think it was specified, but for me I let the user enter negative values. It doesn't affect any of the calculations as long as the intrinsic value is consistent. 

303496263
Posts: 68
Posted 14:05 Jan 28, 2015 |
jpascua wrote:

If the user cannot assign negative values to the weight, then the subtraction operator won't work since it returns new weight object (taking in negative parameters after the subtraction).

My mistake, I meant you can handle those in setters and not in the constructor. I am indeed using setters(setPounds() and setOunces()) to assign values to the member variables.