Dear members and administrators:
Hello to all. Hope/pray all is well.
We have an assignment in which we need to develop a Java console application which acts like a job scheduler. A Job has an id, start date and end date, name, and list of dependent jobs. This is what I’d done so far:
public class MyJob {
private String name;
private int jobId;
private LocalDate dtStart;
private LocalDate dtEnd;
public MyJob(int jobId, LocalDate dtStart, LocalDate endDate, String name){
this.jobId = jobId;
this.dtStart= dtStart;
this.dtEnd = dtEnd;
this.name = name;
}
public int getJobId(){
return jobId;
}
public String getJobName(){
return name;
}
public LocalDate getJobStartDate(){
return dtStart;
}
public LocalDate getJobEndDate(){
return dtEnd;
}
public List<Integer> getJobDependencies(){
//no implementation yet, I am having diffuculty in this
}
@Override
public String toString() {
return getTaskId() + "\t\t\t" +
getJobStartDate() + "\t\t" +
getJobEndDate() + "\t\t\t" +
getJobName();
}
}
Here’s the objective of the program that I’d already resolved:
- Create three instance of MyJobs class and initialize the String “First job”, “second job” and “third job” each. This MUST be the correct order. (NOTE: I'd already resolved this task, using array of MyJobs and array of String, used for loop).
Here’s some of the objectives that I want to ask for anyone’s help:
- Assign random job id to each of the jobs (EDIT: I'd already resolved this task, using random, and list, and put it in a loop together with instantiation of MyJob class).
- Within the start date and end date (example start date starts at January 1, 2019 and ends in January 31, 2019), assign random date range with a minimum of either 4 days or a max of 30 days, on the three Jobs.
- Create a list that serves as a dependent jobs.
Example output I have so far (Please don't mind the HTML code, I just enclosed it using Wrap [HTML] tags around selected text:
HTML Code:
Job id start date end date job name dependencies
101 2019-01-01 2019-01-31 first job
109 2019-01-01 2019-01-31 second job
103 2019-01-01 2019-01-31 third job
Example output I would like to have (Please don't mind the HTML code, I just enclosed it using Wrap [HTML] tags around selected text:
HTML Code:
Job id start date end date job name dependencies
101 2019-01-01 2019-01-04 first job
109 2019-04-01 2019-01-15 second job 101
103 2019-01-15 2019-01-31 third job 101, 109
According to our instructor:
- The job id may, or may not be, in correct order as long as the job name is in order.
- As with the dependencies, you can see job id 103 should have dependencies of 101 and 109, because the program “should not” do third job as long as first job and second job are "not yet" finished.
- Jobs can start at the same date, and may, or may not finished on the same date too.
- Assign second job to be the longest days of all jobs in the output.
I am currently working on the other objectives as the time of this writing, seems I am stuck with the date and dependencies. Also trying to used recursion, but I do not know how to end the recursive call.
I hope someone could give me an idea how to resolved the remaining tasks.
Thank you.
Warmest regards,
Mark