CLASSES NEED TO BUILD:
--------------------------
1. Item class
- a constructor of Item containing an integer identifier and a double weight
- this constructor only allows weight W (0<W<=1)
- throw an exception if constructor passes a bad weight (e.g. W>1 or W<0)
- methods to return items identifier and weight
- a toString method to return a left bracket, identifier, a comma, a space, a weight and
a right bracket (e.g. "(2, 0.359)")
2. Box class
- start counting at 1.0
- list of item object in the box
- a method to return the weight can be added, already added, number of items in the box,
the i-th item in the box (throw exception if i is invalid), list of all items in the box
- toString method contains weight available, weight of items in box, number of items in the
box, list of items in the box
- implement this class with Comparable interface - compare two boxes, compare the weight of
items to pack into boxes, and should return the list of packed boxes
3. Strategy class
- contains Strategy 1 method and Strategy 2 method
- first implement Strategy 1, then implement Strategy 2
- each method accept only a parameter of list of items to pack into boxes and return the
list of packed boxes
4. Test class
- contains the main method
- opens a text file containing a single line with a list of items weights
(i.e. 0.3, 0.249, 0.95, 0.34, 0.21, 0.13, 0.79, 0.2, 0.86)
- creates a list of items
- calls each methods for Strategy 1 and 2
- prints out the resulting list of boxes of each call
SOS~Can anyone help me to finish this program? Thanks a lot!
Come on!
We are glad to help, but we don't do your homework!
What do you think you'll learn if we are doing your work?
So. you should at least try to do it yourself. If you are running into problems, you are welcome to ask questions here.
I'm taking two subjects in the summer semester, and it must be finished within one and half month. Our lecturers gives us quite a lot of assignments to do, i don't have enough time to finish all, so I come to ask for help.
Arj: If you want to get your project done, you'd better start doing it. Ask as many sensible questions as you like, but bear in mind we aren't a free coding service and we're not a substitute for reading the Java docs.
There's no cure for birth and death save to enjoy the interval
Please use [CODE]...your code here...[/CODE] tags when posting code. If you get an error, please post the full error message and stack trace, if present.
* The Best Reasons to Target Windows 8
Learn some of the best reasons why you should seriously consider bringing your Android mobile development expertise to bear on the Windows 8 platform.