-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOperations.java
More file actions
54 lines (47 loc) · 1.14 KB
/
Copy pathOperations.java
File metadata and controls
54 lines (47 loc) · 1.14 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
class Operations {
//the array that represents the main memory
private Premium[] mainMemory;
private int index;
public Operations(int size) {
mainMemory = new Premium[size];
index = 0;
}
public Premium[] getMainMemory() {
return mainMemory;
}
public int getIndex() {
return index;
}
public void setIndex(int index) {
this.index = index;
}
//decrement the request, either basic or premium
public void decRequest(Premium e) {
if (e.isPremium())
e.decPremium();
else if (e.isBasic())
e.decBasic();
}
//check if the element with the name "name" is in memory
public boolean isInMainMemory(String name) {
for (Premium e : mainMemory) {
if (e != null) {
if ((e.getName()).equals(name)) {
return true;
}
}
}
return false;
}
//find and return the element with the name "name"
public Premium getElementMain(String name) {
for (Premium e : mainMemory) {
if (e != null) {
if ((e.getName()).equals(name)) {
return e;
}
}
}
return null;
}
}