-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathItemMap.java
More file actions
52 lines (31 loc) · 1.14 KB
/
ItemMap.java
File metadata and controls
52 lines (31 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
import java.util.HashMap;
import java.util.Hashtable;
public class ItemMap extends HashMap<String, Item>{
// Note : Here we have suggested the usage of a hashmap. However, use a preferred datastructure.
// TODO : Implement any methods required to query/update the datastructure.
public void add(String symbol,Item value ) {// method to add a element
super.put(symbol, value);
}
public float getprice(String key) {// method for get the price
if(super.containsKey(key)==false)
return -1;
else
return super.get(key).get_price();
}
public float make_bid(String key,float price,int id) {// method for update the bid acording to the price
if(super.containsKey(key)==false)
return (float) -1.0;
else {
float updated_price=super.get(key).make_bid(price,id);
return updated_price;
}
}
public float profit_update(String key,int sec,float prft) {// method for updating the profit
if(super.containsKey(key)==false || super.get(key).getSecurity()!=sec)
return -1;
else {
super.get(key).updateprofit(prft);
return 0;
}
}
}