From be160de58bba749420528afbf1172356e92e53e0 Mon Sep 17 00:00:00 2001 From: shellhub Date: Thu, 17 Sep 2020 09:36:07 +0800 Subject: [PATCH] format code --- src/main/java/com/others/RoundRobin.java | 70 ++++++++++---------- src/test/java/com/others/RoundRobinTest.java | 16 ++--- 2 files changed, 43 insertions(+), 43 deletions(-) diff --git a/src/main/java/com/others/RoundRobin.java b/src/main/java/com/others/RoundRobin.java index cb17853d..b50cebeb 100644 --- a/src/main/java/com/others/RoundRobin.java +++ b/src/main/java/com/others/RoundRobin.java @@ -12,36 +12,36 @@ public class RoundRobin { * This method calculates the waiting time for all processes * * @param burstTime an array with burst time for all processes - * @param quantum the quantum quantity - * + * @param quantum the quantum quantity * @return an array with waiting time for all processes */ - public int[] calcWaitingTime(int[] burstTime, int quantum) - { - int n= burstTime.length; + public int[] calcWaitingTime(int[] burstTime, int quantum) { + int n = burstTime.length; //create a copy of burstTime table to executeTime table - int[] executeTIme= new int [n]; - for (int i=0;i readyQueue = new ArrayList<>(); - for(int i=0;i=0) { + if (executeTIme[i] >= 0) { if (executeTIme[i] - quantum > 0) { //add time that have been passed time += quantum; @@ -57,7 +57,7 @@ public class RoundRobin { //mark the process as finished executeTIme[i] = -1; //remove the process that have finished by shrinking queue's length - readyQueue.remove(readyQueue.size()-1); + readyQueue.remove(readyQueue.size() - 1); } else { //add time that have been passed @@ -68,11 +68,13 @@ public class RoundRobin { //mark the process as finished executeTIme[i] = -1; //remove the process that have finished by shrinking queue's length - readyQueue.remove(readyQueue.size()-1); + readyQueue.remove(readyQueue.size() - 1); } } i++; - if(i>=n) i=0; + if (i >= n) { + i = 0; + } } return waitingTime; @@ -82,20 +84,19 @@ public class RoundRobin { /** * This method calculates turn around time for all processes * - * @param burstTime an array with burst time for all processes + * @param burstTime an array with burst time for all processes * @param waitingTime an array with waiting time for all processes - * * @return an array with turnaround time for all processes */ - public int[] calcTurnAroundTime(int[] burstTime, int[] waitingTime) - { - int n= burstTime.length; + public int[] calcTurnAroundTime(int[] burstTime, int[] waitingTime) { + int n = burstTime.length; //initialize the turnaround time table - int[] turnAroundTime= new int [n]; + int[] turnAroundTime = new int[n]; //calculate turnaround time for each process (T.T= W.T + B.T) - for (int i=0; i