import java.util.Scanner;/** * 遊戲類 * * @author * */public class game {person user = new person();computer com = new computer();;int count;/** * 遊戲初始化 */public void gameBegin() {System.out.print("*******************歡迎進入遊戲世界***********************"+ "\n\n\n");System.out.print("\t\t" + "********************" + "\n\n\n");System.out.print("\t\t" + "** 猜拳&開始 **" + "\n\n\n");System.out.print("\t\t" + "********************" + "\n\n\n");Scanner input = new Scanner(System.in);System.out.println("出拳規則:1.剪刀 2.石頭 3.布");System.out.println("請選擇人物:1.劉備 2.曹操 3.孫權");int num = input.nextInt();switch (num) {case 1:user.name = "劉備";break;case 2:user.name = "曹操";break;case 3:user.name = "孫權";break;}System.out.println("要開始遊戲嗎(y/n)");String answer = input.next();if (!answer.equals("y")) {System.exit(0);}}/** * 計算對戰結果 */public int calcResult() {count++;return count;}/** * 顯示對戰結果 */public void showResult() {int numA = user.showFlst();// 擷取使用者選擇的結果int numB = com.showflst();if (numA == numB) {System.out.println("結果:打成平手,下次再和你一分高下");} else if ((numA == 1 && numB == 2) || (numA == 2 && numB == 3)|| (numA == 3 && numB == 1)) {System.out.println("結果:電腦贏!!!呵呵,笨笨,下次加油啊");user.score++;} else {System.out.println("結果:" + user.name + "獲勝!!!恭喜恭喜");com.score++;}}}