この記事では、Java Implemented Shissors Stone Cloth Gameについて説明します。次のように、参照のために共有してください。
choiceanswer.java
public class choiceanswer {string texts [] = {"stone"、 "sassors"、 "cloth"}; int値; //【1 } choiceanswer(int value){this.value = value; } / *** return 0 dean draw、return 1は勝つことを意味します。 } if(value + 1 == c.value ||(value == 3 && c.value == 1)){return 1; } return -1; }}game.java
import java.util.scanner; public class game {void p(string s){system.out.println(s); } void showwelcome(){p( "Welcome ・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・・�userchoice> 3){p("誤って入力しました!再入力してください! "); userchoice = integer.parseint(sc.Nextline()) (Math.random() * 3); userchoice.getText())選択: " + ComputerChoice.getText());}} void start(){showwelcome(); choiceanswer userchoice = getUserchoice(); choiceanswer computerchoice = getComputerChoice(); showresult(userchoice、computerchoice);} system.out.println( "wulin.comテスト結果:");実行結果:
Javaアルゴリズムの詳細については、このサイトに興味のある読者は、「Javaデータ構造とアルゴリズムのチュートリアル」、「Java操作DOMノードのヒントの要約」、「Javaファイルの要約およびディレクトリ操作のヒント」、「Java Cache操作のヒントの要約」というトピックを見ることができます。
この記事がみんなのJavaプログラミングに役立つことを願っています。