-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathProceso.java
More file actions
115 lines (92 loc) · 2.23 KB
/
Proceso.java
File metadata and controls
115 lines (92 loc) · 2.23 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import java.util.Random;
public class Proceso implements Comparable<Proceso> {
Random random=new Random();
//atributos
private boolean seEjecuto;
static int idr=0;
private int id;
private int tiempoR;
private int estado;
private int prioridad;
private int quantum;
private int boletos;
private double usoCpu;
public Proceso(int quantum) {
seEjecuto=false;
idr++;
this.id = idr;
this.tiempoR = random.nextInt(8)+3;
this.estado = random.nextInt(2)+1;
this.prioridad=random.nextInt(4)+1;
this.quantum=quantum;
this.boletos=prioridad*2;
this.usoCpu = 0.0;
}
public int getBoletos(){
return boletos;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public int getTiempoR() {
return tiempoR;
}
public void setTiempoR(int tiempoR) {
this.tiempoR = tiempoR;
seEjecuto=true;
}
public int getEstado() {
return estado;
}
public void setEstado(int estado) {
this.estado = estado;
}
public int getPrioridad() {
return prioridad;
}
public void setPrioridad(int prioridad) {
this.prioridad = prioridad;
}
public Random getRandom() {
return random;
}
public void setRandom(Random random) {
this.random = random;
}
public int getQuantum() {
return quantum;
}
public double getUsoCpu() {
return usoCpu;
}
public void setUsoCpu(double usoCpu) {
this.usoCpu = usoCpu;
}
public void setQuantum(int quantum) {
this.quantum = quantum;
}
public boolean getSeEjecuto(){
return seEjecuto;
}
@Override
public String toString() {
if(tiempoR>9 && id>9){
return "|| "+id+" || "+tiempoR+" || "+estado+" || "+prioridad+" ||";
}
if(id>9){
return "|| "+id+" || "+tiempoR+" || "+estado+" || "+prioridad+" ||";
}
if(tiempoR>9){
return "|| "+id+" || "+tiempoR+" || "+estado+" || "+prioridad+" ||";
}else{
return "|| "+id+" || "+tiempoR+" || "+estado+" || "+prioridad+" ||";
}
}
@Override
public int compareTo(Proceso o) {
return o.getPrioridad()-this.prioridad;
}
}