The Weight class

posted by: Ms. Martin 15 February 2011 No Comment

You will implement a class to represent weights in pounds and ounces.  Your class will have two fields: pounds and ounces.  Recall that there are 16 ounces in a pound.  Weight objects should never keep track of more than 15 ounces, they should convert the value to pounds instead.  Weights can be printed (ex: 1lb 4oz or 3oz or 7lbs 3oz).

Your class will implement the Comparable interface.  Write a client that creates several weights, puts them in an ArrayList, then sorts them.

1 Star2 Stars3 Stars4 Stars5 Stars (7 votes, average: 1.00 out of 5)
Loading ... Loading ...

Leave a comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>