Repository navigation
Expand file tree
/
Copy pathday2.java
More file actions
57 lines (54 loc) · 1.56 KB
/
Copy pathday2.java
File metadata and controls
57 lines (54 loc) · 1.56 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
55
56
57
import java.io.File;
import java.io.FileNotFoundException;
import java.util.*;
public class Main {
public static void main(String[] args) throws FileNotFoundException {
Scanner sc = new Scanner(new File("in.txt"));
int current = 0;
List<Integer> list = new ArrayList<>();
Map<Character,Integer> s = new HashMap<>();
s.put('X', 0);
s.put('Y', 3);
s.put('Z', 6);
s.put('A', 1); // rock
s.put('B', 2); // paper
s.put('C', 3); // scissors
//1 for Rock, 2 for Paper, and 3 for Scissors
while (sc.hasNextLine()) {
String aux = sc.nextLine();
char h = aux.charAt(0);
char b = aux.charAt(2);
if(b == 'Y'){
current += s.get(h); // choose same
}
else if(b =='X'){
char selected;
if(h =='A'){
selected = 'C';
}
else if(h == 'B'){
selected = 'A';
}
else{
selected ='B';
}
current+= s.get(selected);
}
else{
char sel;
if(h =='A'){
sel = 'B';
}
else if(h =='B'){
sel = 'C';
}
else {
sel = 'A';
}
current+= s.get(sel);
}
current += s.get(b);
}
System.out.println(current);
}
}