public void display(Date date) { for (int i = 0; i < this.position; i++) { schedule[i].init(); while (schedule[i].hasMoreOccurrences()) { Date tmp = schedule[i].nextOccurrence(); if (tmp.compareTo(date) == 0) { System.out.println(schedule[i].toString()); schedule[i].init(); break; } } } }
Basically, the above goes through an array of "events." Each event has a way to check if it has more occurrences and a method to get the next occurrence (which has a type date).
The method takes a date and goes through the array and checks every event. For each event, it checks to see if it has more occurrences. If so, it checks to see if this event matches the “specified” date. If so, it prints the event and breaks out of the loop and moves on to the next event in the array. If the next occurrence does not match the specified date, it continues to check until the event has more cases to check.
I know that this SUPEROSED method is designed to print events, however I do not get errors and do not output. I played with him for some time to no avail.
I am 100% sure that my hasMoreOccurrences () and nextOccurrence () methods work correctly because the other parts of the code that rely on them work.
I'm at a standstill: / Thanks for the help :)
EDIT I typed both tmp and date, and I see that they both occur on the same DATE, but not on the same TIME. I don't care about time, only about the date. Any ideas?
source share