The Instruction was to create a Random dates for each object withn the range specified in the instructions below for the interview slot objects to be stored in . I am not exactly sure how to do this
Create a random number of InterviewSlot objects and store them in the slots container.
Use the Math.random() method to create variation in the objects created:
- Make the range of variation of the dates in hours.
- The range should be 30 days, meaning that the dates could vary between say, today and 30 days from now. The max of the range would be equal to 30*24.
- You can set the minimum of the range to 1.
- Make the duration vary between 1 and 60.
Examples of objects:
Thu Apr 02 05:28:59 EDT 2020 duration:18
Fri Mar 27 00:22:32 EDT 2020 duration:48
Wed Apr 01 20:22:32 EDT 2020 duration:8
Sat Mar 28 19:22:32 EDT 2020 duration:31
import java.util.Calendar;
import java.util.Date;
public class InterviewSlot implements Comparable<InterviewSlot> {
Calendar cal = Calendar.getInstance();
private Date startTime = cal.getTime();
private Integer duration;
public InterviewSlot(Date start, Integer d) {
setDuration(d);
setStartTime(start);
}
public void setDuration(Integer duration) {
this.duration = duration;
}
public void setStartTime(Date startTime) {
this.startTime = startTime;
}
public Integer getDuration() {
return duration;
}
public Date getStartTime() {
return startTime;
}
@Override
public String toString() {
// TODO Auto-generated method stub
return "Interview Start " + getStartTime() + "Duration : " + getDuration();
}
@Override
public int compareTo(InterviewSlot s) {
return this.getStartTime().compareTo(s.getStartTime());
// TODO Auto-generated method stub
}
}
import java.awt.List;
import java.util.ArrayList;
public class DataCreator {
public static <E extends Comparable<E>> void outputData(ArrayList<E> l) {
for (E L : l) {
System.out.println(L);
}
}
public static void createIntegers(ArrayList<Integer> a, int num) {
// double random = (int)(Math.random()*((100-1)+1))+1;
for (int i = 0; i < num; i++) {
Integer random = (int) (Math.random() * ((100 - 1) + 1)) + 1;
a.add(random);
}
;
}
public static void createData(ArrayList<InterviewSlot> slots, int num) {
}
}