나는 간단한 질문을 했으므로 간단한 프로그램 인 Rock, Paper Scissors 게임을 작성했지만 지금은 0,1,2가 표시되어 0은 가위, 1 바위이고, 2 종이입니다. 인스턴트 메신저 문제는 메신저가 사용자 입력을주는 방법과 컴퓨터 출력이 숫자를 표시하는 것에서 가위, 바위, 종이를 표시하는 것까지 무엇인지 알려주지 않는 것입니다. }숫자 출력과 입력을 단어로 변환하기
import java.util.Scanner;
import java.lang.Math;
public class Lab3
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
System.out.print("Hello user! lets play ");
System.out.println("Rock, Paper, Scissors.");
System.out.println();
System.out.print("Type in 0 for Scissors, 1 for Rock, or 2 for Paper ");
int userInput = in.nextInt();
int opponentsHand = (int)(Math.random()*3);
if (userInput == opponentsHand)
{
System.out.print("Darth Vader has played " + opponentsHand);
System.out.println(" Despite your efforts of playing " + userInput + ", this battle has ended in a draw!");
}
if (userInput < opponentsHand && opponentsHand != 2)
{
System.out.print("Darth vader has played "+ opponentsHand);
System.out.println(", You played " + userInput + "You have Lost");
}
else if (userInput < opponentsHand && opponentsHand == 2)
{
System.out.print("Darth Vader has played " + opponentsHand);
System.out.println(" You played " + userInput + " You have won");
}
if (userInput > opponentsHand && opponentsHand != 0)
{
System.out.print("Darth Vader has played " + opponentsHand);
System.out.println(" You have played " + userInput + " You have won");
}
else if (userInput > opponentsHand && opponentsHand == 0)
{
System.out.print("Darth Vader has played " + opponentsHand);
System.out.println(" You have played " + userInput + " You have lost");
}
}
이
자바 스크립트? – ndugger