eclipse编辑五子棋小游戏,按钮重新开始的代码
1个回答
2017-06-28
展开全部
import java.util.Scanner;public class FiveChessGame {public static void display(char[][] arr) {// 图形显示函数System.out.print(" ");for (char i = '0'; i = 5) {return 1;}} else {count = 0;}}count = 0;for (int i = 0; i = 5) {return 1;}} else {count = 0;}}count = 0;if (a >= b) {int j = 0;for (int i = a - b; i = 5) {return 1;}} else {count = 0;j++;}}} else {int j = 0;for (int i = b - a; i = 5) {return 1;}} else {count = 0;j++;}}}int j = a + b;count = 0;if (a + b = 5) {return 1;}} else {count = 0;j--;}}} else {j = 15;for (int i = a + b - 15; i = 5) {return 1;}} else {count = 0;j--;}}}} else {// 判断白色胜int count = 0;for (int i = 0; i = 5) {return 2;}} else {count = 0;}}count = 0;for (int i = 0; i = 5) {return 2;}} else {count = 0;}}count = 0;if (a >= b) {int j = 0;for (int i = a - b; i = 5) {return 2;}} else {count = 0;j++;}}} else {int j = 0;for (int i = b - a; i = 5) {return 2;}} else {count = 0;j++;}}}int j = a + b;count = 0;if (a + b = 5) {return 2;}} else {count = 0;j--;}}} else {j = 15;for (int i = a + b - 15; i = 5) {return 2;}} else {count = 0;j--;}}}}return 0;}public static void main(String[] args) {// TODO Auto-generated method stubScanner sc = new Scanner(System.in);char[][] arr = new char[16][16];for (int i = 0; i < 16; i++)// 二维数组初始化for (int j = 0; j < 16; j++)arr[i][j] = '.';display(arr);int i = 0;while (true) {if (i % 2 == 0) {System.out.println("请黑方落子:");String in = sc.next();char c1 = in.charAt(0);char c2 = in.charAt(1);int a = getNum(c1);int b = getNum(c2);if (arr[a][b] != '.') {System.out.println("该位置已经有棋子,请重新输入!");} else {arr[a][b] = '@';display(arr);int result = isWinner('@', arr, a, b);if (result == 1) {System.out.println("黑方获胜!");return;}i++;}} else {System.out.println("请白方落子:");String in = sc.next();char c1 = in.charAt(0);char c2 = in.charAt(1);int a = getNum(c1);int b = getNum(c2);if (arr[a][b] != '.') {System.out.println("该位置已经有棋子,请重新输入!");} else {arr[a][b] = 'O';display(arr);int result = isWinner('O', arr, a, b);if (result == 2) {System.out.println("白方获胜!");return;}i++;}}}}}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询