简体   繁体   中英

java loop logic mechanism

i am making a scheduling system. my problem now is how to display the schedule. my query statement displays the schedule of a particular teacher on a particular day 在此处输入图片说明

but there is also a 08:00-09:00 class but this teacher is vacant at that time.

what i would like to do is put the list of time in a list ... then compare it to the list of time of the teacher ... if time (list) is not on time (teacher) then it will put null.

this will be the content of the list

在此处输入图片说明

again the loop should compare two list ... if if time (list) is not on time (teacher) then it will put null.

what loop mechanism will i used? i think my problem is my loop logic

i tried

  • list of time - in ascending order
  • list of time(teacher)
  • list of subject

    if (list time == list of time(teacher)) save list subject break else save null break

but its saving 6 data instead of 3 .. i tried doing this during query statement but i cant

i think its if (list time.size() != list time(teacher).size()) find missing time then null values ... but how will i do it?

Maybe this logic could help you out.

Previous (End time) |   Current (End time of the previous sched)    |   Next (Start Time of the next sched)

         8                              8                                       9


if CURRENT_TIME is equal to NEXT_TIME then
    // probably this sched is not vacant
else
    // current time TO next start time is vacant.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM