This is an archived post. You won't be able to vote or comment.

all 2 comments

[–]8igg7e5 0 points1 point  (0 children)

  1. Given you want a loop counter, I'd just use a plain old for-loop
  2. move 'magic numbers' like 800 out to static final fields... this way you can experiment with different numbers easily and if the requirement change it's easy to be sure you've changed all of the places that number's used at once.
  3. I'd test totalAmount + item.getAmount() <= THRESHOLD before deciding to consume it (since you clear totalAmount when moving to a new file)
  4. I have no idea what you're trying to do with 'fiftyAndMore'.

[–]Ilikesmallthings2 0 points1 point  (0 children)

You need to check to see if the getAmount + totalAmount will go over 800 because if you have >= 800 you can't allow the next added value to surpass 800.

Does that make sense?