-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathResult.java
More file actions
37 lines (30 loc) · 885 Bytes
/
Result.java
File metadata and controls
37 lines (30 loc) · 885 Bytes
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
import java.util.Map;
public class Result<T extends Person, U extends Integer> {
private Map<T, U> result;
public Map<? extends T, ? extends U> getResult() {
return result;
}
public void setResult(Result<? extends T, ? extends U> from) {
this.result.putAll(from.result);
}
public Result<? super T, ? super U> addResult(Result<? super T, ? super U> to) {
to.result.putAll(this.result);
return to;
}
public Result(Map<T, U> result) {
this.result = result;
}
public int sum() {
Integer sum = 0;
for (U x : result.values()) {
sum += x.intValue();
}
return sum;
}
public <X extends Person> void findPerson(X x) {
if (result.containsKey(x))
System.out.println("true!");
else
System.out.println("false");
}
}