-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGeneration.java
More file actions
49 lines (39 loc) · 1.36 KB
/
Generation.java
File metadata and controls
49 lines (39 loc) · 1.36 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
package com.generation;
import java.util.Scanner; // importar Scanner
public class Generation {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner s = new Scanner(System.in); // crear objeto Scanner con new
System.out.print("Turno del jugador 1 (introduzca piedra, papel o tijeras): ");
String j1 = s.nextLine();
System.out.print("Turno del jugador 2 (introduzca piedra, papel o tijeras): ");
String j2 = s.nextLine();
if (j1.equals(j2)) {
System.out.println("Empate");
} else {
int g = 2;
switch (j1) {
case "piedra":
if (j2==("tijeras")) {
g = 1;
}
break; // colocar los breaks
case "papel":
if (j2==("piedra")) {
g = 1;
}
break;
case "tijeras":
if (j2==("papel")) {
g = 1;
}
break;
default:
System.out.println("Entrada inválida"); // se coloca el default
return;
}
System.out.println("Gana el jugador " + g);
}
s.close();
}
}