Last active
March 6, 2025 04:04
-
Star
(0)
You must be signed in to star a gist -
Fork
(148)
You must be signed in to fork a gist
-
-
Save eduardojesus12/f271c36ea86bb0498df5d8b4ab6ab258 to your computer and use it in GitHub Desktop.
Trabajar con código de otros 4
This file contains hidden or 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
package com.generation;
import java.util.Scanner; // se nombra la libreria para el uso del scanner
public class Codigo4 {
public statatic void main (String[] args){ // hacia falta la funcion para correr el codigo
Scanner s = new Scanner( system.in); // instanciamos para recibir el dato
System.out.print("Turno del jugador 1 (introduzca piedra, papel o tijeras): ");
String j1 = s.next();
}
}