Hi. I'm writing a web based scheduling system for university. I've created the time slot for every 30 minutes. But how to label each of every slot? for example:- S1 -> 800am - 830am S2 -> 830am - 900am S3 -> 900am - 930am . . . S16 -> 530pm - 600pm here is my coding. What makes me confused is I don't know how and where to label my time slot. <pre lang="java"> package GA; import java.util.ArrayList; //set time to every 30 minutes public class TimeSlot{ private int hour; private int minute; private ArrayList TS = new ArrayList (); public TimeSlot(int hour,int minute){ this.hour = 0; this.minute = 0; setHour(hour); setMinute(minute);} public TimeSlot(int minute){ this.hour = 0; this.minute = 0; setMinute(minute);} //return hour public int getHour(){return hour;} //return minute public int getMinute(){return minute;} //param hour the hour to set //supaya less than 24 hours public void setHour(int hour){ //24 hours if((hour >= 0) && (hour < 24)){ this.hour = hour;} } //param minute the minute to set //setkan exact waktu xlebih 60 minute public void setMinute(int minute){ if(minute >0){ this.hour += minute/60; this.minute = 30 * ((minute % 60) / 30);} else{ minute = 0;} } //to duplicate the of hour and minute @Override public boolean equals(Object obj){ if(obj instanceof TimeSlot){ TimeSlot timeObj = (TimeSlot) obj; return ((hour == timeObj.hour) && (minute == timeObj.minute));} return false; } @Override public String toString(){ return hour +":" +minute;} public int compareTo(TimeSlot s){ if(hour == s.hour){ return Integer.compare(minute, s.minute); } return Integer.compare(hour,s.hour); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)