-
Notifications
You must be signed in to change notification settings - Fork 0
/
SavingFieldMap.java
105 lines (85 loc) · 1.78 KB
/
SavingFieldMap.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
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
package game;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
/**
* This class will produce the layout for the savingField
*
*/
public class SavingFieldMap {
private HashMap<Integer, SavingField> currentSavingField;
public SavingFieldMap() {
this.setCurrentSavingField(new HashMap<Integer, SavingField>());
}
/**
*
* @param SavingField
*/
public SavingFieldMap(ArrayList<SavingField> SavingField) {
this();
int loop = 0;
for (SavingField sf : SavingField) {
this.addSavingField(loop + 1, sf);
loop++;
}
}
/**
* Getter for the HashMap currentSavingField
*
* @return the currentSavingField
*/
public HashMap<Integer, SavingField> getCurrentSavingField() {
return currentSavingField;
}
/**
* Setter for the HaspMap currentSavingField
*
* @param currentSavingField the currentSavingField to set
*/
public void setCurrentSavingField(HashMap<Integer, SavingField> currentSavingField) {
this.currentSavingField = currentSavingField;
}
/**
*
* @param key
* @param value
*/
public void addSavingField(int key, SavingField value) {
this.getCurrentSavingField().put(key, value);
}
/**
*
* @param choice
* @return
*/
public boolean contains(int choice) {
return this.getCurrentSavingField().containsKey(choice);
}
/**
*
* @param choice
* @return
*/
public SavingField getChosenSavingField(int choice) {
return this.getCurrentSavingField().get(choice);
}
/**
*
* @return
*/
public int size() {
return this.getCurrentSavingField().size();
}
/**
*
*/
@Override
public String toString() {
String menu = "";
Iterator it = this.getCurrentSavingField().entrySet().iterator();
while (it.hasNext()) {
menu += it.next().toString() + "\n";
}
return menu;
}
}