Skip to content

Instantly share code, notes, and snippets.

@eduardojesus12
Last active May 10, 2024 18:53
Show Gist options
  • Save eduardojesus12/f271c36ea86bb0498df5d8b4ab6ab258 to your computer and use it in GitHub Desktop.
Save eduardojesus12/f271c36ea86bb0498df5d8b4ab6ab258 to your computer and use it in GitHub Desktop.
Trabajar con código de otros 4
package com.generation;
public class Codigo4 {
Scanner s = new Scanner();
System.out.print("Turno del jugador 1 (introduzca piedra, papel o tijeras): ");
String j1 = s.nextLine();
System.out.print("Turno del jugador 1 (introduzca piedra, papel o tijeras): ");
Scanner s2 = new Scanner();
String j2 = s.nextLine();
if (j1 == j2)) {
System.out.println("Empate");
} else {
int g = 2;
switch(j1) {
case "piedra":
if (j2 == "tijeras") {
g = 1;
}
case "papel":
if (j2 == "piedra") {
g = 1;
case "tijera":
if (j2.equals("papel")) {
g = 1;
}
break;
default:
}
System.out.println("Gana el jugador " + g);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment