Skip to content

Instantly share code, notes, and snippets.

@SergioRmz
Forked from eduardojesus12/Ejercicio4.java
Created March 29, 2023 06:33
Show Gist options
  • Save SergioRmz/1c061adf4ed0c617e75d873f093c3ae3 to your computer and use it in GitHub Desktop.
Save SergioRmz/1c061adf4ed0c617e75d873f093c3ae3 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