// Path: thread/utilClasses/Process.java
// public class Process {
// 	public String jobName;
// 	public int arrivalTime;
// 	public int cpuTime;
// 	public int priority;
// 	public char symbol;
// 	
// 	public Process(){
// 		this.jobName = "";
// 		this.arrivalTime = 0;
// 		this.cpuTime = 0;
// 		this.priority = 1;
// 		this.symbol = '0';
// 	}
// 	
// 	public Process(String jobName, int arrivalTime, int cpuTime, char symbol){
// 		this.jobName = jobName;
// 		this.arrivalTime = arrivalTime;
// 		this.cpuTime = cpuTime;
// 		this.priority = 1;
// 		this.symbol = symbol;
// 	}
// 	
// 	public Process(String jobName, int arrivalTime, int cpuTime, int priority, char symbol){
// 		this.jobName = jobName;
// 		this.arrivalTime = arrivalTime;
// 		this.cpuTime = cpuTime;
// 		this.priority = priority;
// 		this.symbol = symbol;
// 	}
// 	
// }
// 
// Path: thread/utilClasses/Result.java
// public class Result {
// 	public String jobName;
// 	public char symbol;
// 	public float waitingTime;
// 	
// 	public Result() {
// 		this.jobName = "EMPTY";
// 		this.symbol = ' ';
// 		waitingTime = -1;
// 	}
// 	
// 	public Result(String jobName, char symbol){
// 		this.jobName = jobName;
// 		this.symbol = symbol;
// 		waitingTime = -1;
// 	}
// 	
// 	public Result(String jobName, char symbol, float waitingTime){
// 		this.jobName = jobName;
// 		this.symbol = symbol;
// 		this.waitingTime = waitingTime;
// 	}
// }


import java.util.Queue;
import thread.utilClasses.Process;
import thread.utilClasses.Result;
import java.util.LinkedList;

			//run the program
			if(!waitingQueue.isEmpty()){	//when there is process to be processed
				
				order(waitingQueue);

				waitingQueue.element().cpuTime -= CPU_CYCLE_TIME;
				waitingQueue.element().arrivalTime += CPU_CYCLE_TIME;
				
				if(waitingQueue.element().cpuTime<=0){	//process ends
					int waitingTime = time - waitingQueue.element().arrivalTime + CPU_CYCLE_TIME;
					result.add(new Result(waitingQueue.element().jobName, waitingQueue.element().symbol, waitingTime));
					
					waitingQueue.remove();
				}else{
					result.add(new Result(waitingQueue.element().jobName, waitingQueue.element().symbol));
				}
				
			}else{							//idle time, no process is waiting
				result.add(new Result());
			}
			
			time += CPU_CYCLE_TIME;
		}
		
		
		return result;
	}
	
	private void order(Queue<Process> waitingQueue){
		int waitingQueueLength = waitingQueue.size();

// Path: thread/utilClasses/Process.java
// public class Process {
// 	public String jobName;
// 	public int arrivalTime;
// 	public int cpuTime;
// 	public int priority;
// 	public char symbol;
// 	
// 	public Process(){
// 		this.jobName = "";
// 		this.arrivalTime = 0;
// 		this.cpuTime = 0;
// 		this.priority = 1;
// 		this.symbol = '0';
// 	}
// 	
// 	public Process(String jobName, int arrivalTime, int cpuTime, char symbol){
// 		this.jobName = jobName;
// 		this.arrivalTime = arrivalTime;
// 		this.cpuTime = cpuTime;
// 		this.priority = 1;
// 		this.symbol = symbol;
// 	}
// 	
// 	public Process(String jobName, int arrivalTime, int cpuTime, int priority, char symbol){
// 		this.jobName = jobName;
// 		this.arrivalTime = arrivalTime;
// 		this.cpuTime = cpuTime;
// 		this.priority = priority;
// 		this.symbol = symbol;
// 	}
// 	
// }
// 
// Path: thread/utilClasses/Result.java
// public class Result {
// 	public String jobName;
// 	public char symbol;
// 	public float waitingTime;
// 	
// 	public Result() {
// 		this.jobName = "EMPTY";
// 		this.symbol = ' ';
// 		waitingTime = -1;
// 	}
// 	
// 	public Result(String jobName, char symbol){
// 		this.jobName = jobName;
// 		this.symbol = symbol;
// 		waitingTime = -1;
// 	}
// 	
// 	public Result(String jobName, char symbol, float waitingTime){
// 		this.jobName = jobName;
// 		this.symbol = symbol;
// 		this.waitingTime = waitingTime;
// 	}
// }


// Path: thread/shortestJob/nonpremitive/CPU.java
import java.util.Queue;
import thread.utilClasses.Process;
import thread.utilClasses.Result;
import java.util.LinkedList;

			//run the program
			if(!waitingQueue.isEmpty()){	//when there is process to be processed
				
				order(waitingQueue);

				waitingQueue.element().cpuTime -= CPU_CYCLE_TIME;
				waitingQueue.element().arrivalTime += CPU_CYCLE_TIME;
				
				if(waitingQueue.element().cpuTime<=0){	//process ends
					int waitingTime = time - waitingQueue.element().arrivalTime + CPU_CYCLE_TIME;
					result.add(new Result(waitingQueue.element().jobName, waitingQueue.element().symbol, waitingTime));
					
					waitingQueue.remove();
				}else{
					result.add(new Result(waitingQueue.element().jobName, waitingQueue.element().symbol));
				}
				
			}else{							//idle time, no process is waiting
				result.add(new Result());
			}
			
			time += CPU_CYCLE_TIME;
		}
		
		
		return result;
	}
	
	private void order(Queue<Process> waitingQueue){
		int waitingQueueLength = waitingQueue.size();

		Process[] processes = new Process[waitingQueueLength];
