-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRecipe.java
60 lines (52 loc) · 1.37 KB
/
Recipe.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
public class Recipe
{
private int id;
private int time;
private int[] resources;
// add global dictionary variable here
// Constructors
public Recipe()
{
id = -1;
time = -1;
resources = {0, 0, 0, 0};
}
public Recipe(int i)
{
id = i;
time = -1;
resources = {0, 0, 0, 0};
}
public Recipe(int i, int t, int[] r)
{
id = i;
time = t;
for (int i = 0; i < 4; i++)
{
resources[i] = r[i];
}
}
// Getters / Setters
public static Recipe getRecipe(int shipID)
{
makeDictionary(); // Instantiates the dictionary used for searching
Stack<Task> dict = new Stack<Task>(); // Copies the dictionary so the orignial is not changed
dict.addAll(dictionary);
for (int i = 0; i < dictionary.size(); i++) // Searches through the dictionary stack until the proper ID is found
{
a = dict.pop();
if (a.getID() == shipID)
{
return a;
}
}
return new Recipe(shipID);
}
public void makeDictionary() // Creates the dictionary if it has not already been made
{
if (dictionary.size() < // Total number of recipes)
{
// Build dictionary
}
}
}