-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProcess.java
70 lines (57 loc) · 1.54 KB
/
Process.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
Author: Liam O'Shea
File: Process.java
Date: November 25 2018
Description: This class describes a Process object. The class keeps track of Process ID, time required,
priority level, and the process' time of arrival.
toString and compareTo have been overridden. Process is comparable by priority.
*/
public class Process implements Comparable<Process> {
private int id;
private int timeReqd;
private int priority;
private int timeArrival;
public Process(int id, int timeReqd, int priority, int timeArrival){
this.id = id;
this.timeReqd = timeReqd;
this.priority = priority;
this.timeArrival = timeArrival;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getTimeReqd() {
return timeReqd;
}
public void setTimeReqd(int timeReqd) {
this.timeReqd = timeReqd;
}
public int getPriority() {
return priority;
}
public void setPriority(int priority) {
this.priority = priority;
}
public int getTimeArrival() {
return timeArrival;
}
public void setTimeArrival(int timeArrival) {
this.timeArrival = timeArrival;
}
public String toString(){
return "(" + id + "," + timeReqd + "," + priority + ")";
}
@Override
public int compareTo(Process p) {
if(p.priority < priority){
return 1;
} else if(p.priority > priority){
return -1;
} else{
return 0;
}
}
}