mike karl wrote:i have to write a method setOrder() which takes enumeration constant defined in Report so iterating over Bills is performed in the order specified by this constant and i have have no clue where to start.
this is what i have so far, let me know what i did wrong and what i should do next.
There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
fred rosenberger wrote:
mike karl wrote:i have to write a method setOrder() which takes enumeration constant defined in Report so iterating over Bills is performed in the order specified by this constant and i have have no clue where to start.
this is what i have so far, let me know what i did wrong and what i should do next.
What you did wrong was to start writing code without thinking about what you should do.
The single most important thing a programmer needs to do is NOT WRITE CODE. Before committing a single byte to file, you should think through the problem in very NON-java terms. you should pretend you are explaining to a child what needs to be done.
Only when you've done that, revised it and simplified it several times, should you write any actual code.
So I would say your next step is to delete what you have, turn off your computer, and put pencil to paper.
mike karl wrote:is it really that badly done,
this is my second semester in programming and my teacher doesnt explain much, im not sure how i can revise this if im not even sure what this is, i never used iterators. i never set up a enumerator to perform sorting. i need some helpful advise
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
mike karl wrote:
Winston Gutkowski wrote:
mike karl wrote:is it really that badly done,
Fraid so; although I think I understand what you were attempting to achieve.
this is my second semester in programming and my teacher doesnt explain much, im not sure how i can revise this if im not even sure what this is, i never used iterators. i never set up a enumerator to perform sorting. i need some helpful advise
And you've already received it. Most of us have BTDTGTTS, so unless you haven't shown any effort (which you plainly have), we're not trying to belittle you.
The fact is that Fred's absolutely right, you've decided on an implementation (your code) before you've understood the problem - and that's always a bad sign - and now you're in the position of trying to defend the indefensible.
My advice: StopCoding (←click) before you have too much invested in this to turn back.
There are plainly some good ideas in your attempt; it just happens to be wrong.
Here's a possibility for you: Have your enum (one of your good ideas) implement java.util.Comparator<Bill>. Have a think about it and see if it makes any sense.
Winston