binibiningtinamoran

ProcessTester

Nov 18th, 2019
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.23 KB | None | 0 0
  1. import java.util.Arrays;
  2.  
  3. public class ProcessTester {
  4.  
  5.     public static void main(String[] args) {
  6.  
  7.         Process one = new Process(3, 1);
  8.         Process two = new Process(4, 8);
  9.         Process three = new Process(9, 1);
  10.         Process four = new Process(5, 6);
  11.         Process five = new Process(7, 3);
  12.         Process six = new Process(1, 4);
  13.  
  14.         Process[] processes= new Process[]{one, two, three, four, five, six};
  15.  
  16.         System.out.println("Before sorting...");
  17.         for (Process p : processes) {
  18.             System.out.println(p.toString());
  19.             System.out.println();
  20.         }
  21.  
  22.         System.out.println();
  23.  
  24.         Arrays.sort(processes, Process.ARRIVAL_TIME_COMPARATOR);
  25.         System.out.println("After sorting, based on ARRIVAL time ordering");
  26.         for (Process p : processes) {
  27.             System.out.println(p.toString());
  28.             System.out.println();
  29.         }
  30.  
  31.         System.out.println();
  32.  
  33.         Arrays.sort(processes, Process.PROCESS_TIME_COMPARATOR);
  34.         System.out.println("After sorting, based on PROCESS time ordering");
  35.         for (Process p : processes) {
  36.             System.out.println(p.toString());
  37.             System.out.println();
  38.         }
  39.     }
  40. }
Add Comment
Please, Sign In to add comment