ANONYMOUS wrote:
Actually sorry to make my question more brief, I just would like to ask instead of returning exception or null pointer [both of these give error] what should we do if it's out of bound from the index?
Firstly, for future reference please avoid sharing what amounts to pseudocode with other students. The project is not just assessing your ability to write Java, but your ability to design the system using the features Java provides. In this case I am not concerned, as the pseudocode you have provided is not likely to give any other students an unfair advantage.
The task you have been asked to solve has no concept of an "index", so there is no specification as to what to do with an index out of bounds. If you are using an index as part of your implementation, how to handle it being out of bounds is part of your own design.
From the information you have provided, I think your design does not solve the task as stated. To be frank, it looks logically almost identical to the (very, very wrong) solution that ChatGPT generated when I tested it. I encourage you to read the task and documentation again carefully and make sure you understand it. Make sure you understand what a double ended iterator is: It is an iterator that can consume a sequence from both ends, not one that can move a cursor back and forth. Then I suggest you construct some test cases and attempt to do them by hand yourself, as though you are the StudentListIterator. The logic required is not difficult, but I have seen a lot of students struggling because they launch straight into the code without planning out their strategy, and then find that they have not considered all the possibilities. We have a small test for it, but consider how your StudentListIterator will behave if you call next()
and reverseNext()
alternatingly.
Hope that helps.
Gozz