Last active
August 29, 2024 19:02
-
-
Save eduardojesus12/f271c36ea86bb0498df5d8b4ab6ab258 to your computer and use it in GitHub Desktop.
Trabajar con código de otros 4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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