Este team de expertos luego de algunos días de trabajo y recopilación de de datos, hallamos la respuesta, esperamos que resulte de utilidad para tu plan.
Ejemplo 1: piedra papel tijeras java
import java.util.Scanner;
public classrps2
public void rps2()
Scanner sage = new Scanner(System.in);int b;
b =1;
System.out.println("Play again? Y(8), N(9)?");int yes=8, no =9;intinput;input= sage.nextInt();if(input== yes)
System.out.println("Rock,Paper,Scissors!");else
System.out.println("Thanks for playing!");
Ejemplo 2: piedra papel tijeras java
import java.util.Scanner;import java.util.Random;
public classrps
public static void main (String args[])intinput;int b =1;
Scanner sage = new Scanner(System.in);
Random rnd = new Random();
System.out.println("Rock Paper Scissors, by Sage!");
System.out.println("Select 1, 2, 3, for Rock, Paper, Scissors");//Menu Present, pretty bad still
while(b !=0)int rock =1, paper =2, scissors =3;input= sage.nextInt();int randomNumber = rnd.nextInt(3-1+1)+1;if(randomNumber == rock)if(input== rock)
System.out.println("Rock vs. Rock, ITS A TIE!");elseif(input== paper)
System.out.println("Rock vs. Paper! You win!");elseif(input== scissors)
System.out.println("Rock vs. Scissors! You lose!");//These blocks establish options if the computer got Rock
elseif(randomNumber == paper)if(input== rock)
System.out.println("Paper vs. Rock! You lose!");elseif(input== scissors)
System.out.println("Paper vs. Scissors! You win!");elseif(input== paper)
System.out.println("Paper vs. Paper! Its a tie!");//These blocks establish the options if comp. got paper
elseif(randomNumber == scissors)if(input== rock)
System.out.println("Scissors vs. Rock! You win!");elseif(input== scissors)
System.out.println("Scissors vs. Scissors, ITS A TIE!");elseif(input== paper)
System.out.println("Scissors vs Paper! You lose!");//These blocks establish if the computer got scissors.
rps2 rps2Object = new rps2();
rps2Object.rps2();
Al final de la post puedes encontrar las observaciones de otros desarrolladores, tú de igual forma tienes la habilidad insertar el tuyo si te apetece.
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)