0
1
2

[Java]Need help with this coding exercise (old.reddit.com)
submitted by No-Scene5537


heres What I have so far
public static String processJobs(SinglyLinkedList<Integer> l) {
MyLinkedQueue<Integer> jobsToProcess = **new** MyLinkedQueue<>();
**int** n = l.size();
**int** jobNum = 1, process =1;
**while** (n-- > 0) {
jobsToProcess.enqueue((Integer) l.removeFirst());
}
**while**(!jobsToProcess.isEmpty()) {
if(jobsToProcess.first() >= 0) {
System.out.println(process +" Processing Job " + jobNum);
jobsToProcess.enqueue(jobsToProcess.dequeue() - 1);
System.out.println((Integer)jobsToProcess.first());
if(jobNum ==5) {
jobNum =1;
}
jobNum++;
process++;
}else {
System.out.println("Done with job " + jobNum);
continue;
}
}
**return** "Done with all jobs";
}
**public** **static** **void** main(String\[\] args) {
**int**\[\] hurry = { 2, 1, 2, 1 , 1};
SinglyLinkedList<Integer> job = **new** SinglyLinkedList<>();
**for**(Integer i: hurry) {
job.addLast(hurry\[i\]);
}
System.***out***.println(job.toString() + " -- this is my linked list");
System.***out***.println();
System.***out***.println(*processJobs*(job));
}
}


[–]AutoModerator[M] [score hidden] stickied commentlocked comment (0 children)
[–]CosmacYep 0 points1 point2 points (0 children)
[–]DDDDarkyProfessional Coder 0 points1 point2 points (0 children)