Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Comparator;
- import java.util.LinkedList;
- import java.util.Scanner;
- import java.util.Collections;
- public class ProcessMain {
- public static void main(String[] args) {
- Scanner in = new Scanner(System.in);
- int n = in.nextInt();
- in.nextLine();
- LinkedList<Process> processes = new LinkedList<Process>();
- //Lengkapi
- for (int x = 0; x < n; x++) {
- Process temp = new Process(in.next(), in.nextInt());
- processes.add(temp);
- }
- Collections.sort(processes, Comparator.comparingInt(Process::getBurstTime));
- processes.forEach(System.out::println);
- System.out.println("Semua process telah selesai dijalankan.");
- }
- }
- class Process {
- private final String processName;
- private final int burstTime;
- public Process(String processName, int burstTime) {
- //Lengkapi
- this.processName = processName;
- this.burstTime = burstTime;
- }
- public int getBurstTime() {
- //Lengkapi
- return burstTime;
- }
- public String getProcessName() {
- //Lengkapi
- return processName;
- }
- @Override
- public String toString() {
- return processName + " dijalankan sebanyak "
- + burstTime + " burst time.";
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement