最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

java實(shí)現(xiàn)雙人五子棋游戲

 更新時(shí)間:2022年05月06日 15:23:27   作者:寒夜清風(fēng)  
這篇文章主要為大家詳細(xì)介紹了java實(shí)現(xiàn)雙人五子棋游戲,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了java實(shí)現(xiàn)雙人五子棋游戲的具體代碼,供大家參考,具體內(nèi)容如下

通過(guò) 上下左右 控制棋盤(pán)走動(dòng)  空格落子   (深度優(yōu)先搜索)

package day_1;?
?
import java.awt.*;
import javax.swing.*;
?
import java.awt.event.*;
?
public class CircleRun extends JFrame {
?? ?/**
?? ? *?
?? ? */
?? ?MyPanel mp = null;
?
?? ?public static void main(String[] args) {
?? ??? ?CircleRun cr = new CircleRun();
?? ?}
?
?? ?public CircleRun() {
?
?? ??? ?mp = new MyPanel();
?? ??? ?this.add(mp);
?? ??? ?this.addKeyListener(mp);
?? ??? ?this.setTitle("雙人五子棋正式版3.0");
?? ??? ?this.setSize(518, 538);// 設(shè)置窗體大小
?? ??? ?this.setLocation(340, 50);// 設(shè)置出現(xiàn)的位置
?? ??? ?this.setVisible(true);// 設(shè)置為可見(jiàn)
?? ??? ?this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
?? ??? ?JOptionPane.showMessageDialog(this, "雙人五子棋游戲說(shuō)明:通過(guò)←↑→↓控制旗子走向,空格下子先滿五個(gè)子勝利", "游戲說(shuō)明", JOptionPane.WARNING_MESSAGE);
?? ?}// 游戲說(shuō)明
}
?
class Text2Frame {// 設(shè)置一個(gè)交互框
?? ?JTextField jt1 = new JTextField(); // new一個(gè)文本框
?? ?JTextArea jt2 = new JTextArea(); // new一個(gè)文本區(qū)
?
?? ?JTextArea jt4 = new JTextArea(); // new一個(gè)文本區(qū)
?
?? ?Text2Frame() {
?
?? ??? ?JScrollPane jsp = new JScrollPane(jt2); // new一個(gè)滾條
?? ??? ?String title = "正在思考。。。。";
?? ??? ?JFrame jf = new JFrame(title);
?? ??? ?Container container = jf.getContentPane();
?? ??? ?// container.setBackground(Color.yellow); //容器的背景色
?? ??? ?jf.setVisible(true); // 窗體可見(jiàn)
?? ??? ?jf.setLocation(150, 50);
?? ??? ?jf.setSize(300, 150); // 窗體大小
?? ??? ?jf.setLayout(new BorderLayout()); // 邊界布局
?? ??? ?jf.add(BorderLayout.NORTH, jt1); // 文本框邊界頂部放置
?? ??? ?jt1.setBackground(Color.yellow);
?? ??? ?jf.add(BorderLayout.CENTER, jt2); // 文本框邊界中間放置
?? ??? ?jf.add(BorderLayout.EAST, jt4); // 文本框邊界中間放置
?? ??? ?jt2.setBackground(Color.red);
?
?? ??? ?jt2.setFont(new Font("宋體", Font.PLAIN, 30));
?
?? ?}
?
?? ?void add(String a) {
?? ??? ?jt2.setText(a);
?
?? ?}
?
};
?
class Text3Frame {
?? ?JTextField jt1 = new JTextField(); // new一個(gè)文本框
?? ?JTextArea jt2 = new JTextArea(); // new一個(gè)文本區(qū)
?
?? ?JTextArea jt4 = new JTextArea(); // new一個(gè)文本區(qū)
?
?? ?Text3Frame() {
?
?? ??? ?JScrollPane jsp = new JScrollPane(jt2); // new一個(gè)滾條
?? ??? ?String title = "當(dāng)前坐標(biāo)";
?? ??? ?JFrame jf = new JFrame(title);
?? ??? ?Container container = jf.getContentPane();
?? ??? ?// container.setBackground(Color.yellow); //容器的背景色
?? ??? ?jf.setVisible(true); // 窗體可見(jiàn)
?? ??? ?jf.setLocation(140, 180);
?? ??? ?jf.setSize(300, 200); // 窗體大小
?? ??? ?jf.setLayout(new BorderLayout()); // 邊界布局
?? ??? ?jf.add(BorderLayout.NORTH, jt1); // 文本框邊界頂部放置
?? ??? ?jt1.setBackground(Color.yellow);
?? ??? ?jf.add(BorderLayout.CENTER, jt2); // 文本框邊界中間放置
?? ??? ?jf.add(BorderLayout.EAST, jt4); // 文本框邊界中間放置
?? ??? ?jt2.setBackground(Color.green);
?
?? ??? ?jt2.setFont(new Font("宋體", Font.PLAIN, 30));
?
?? ?}
?
?? ?void add(String a) {
?? ??? ?jt2.setText(a);
?
?? ?}
?
?? ?String shu(int a, int b) {
?? ??? ?return "當(dāng)前坐標(biāo)(" + a + "," + b + ")";
?? ?}
?
};
?
// 定義自己的面板
class MyPanel extends JPanel implements KeyListener {
?? ?/**
?? ? *?
?? ? */
?? ?private static final long serialVersionUID = 4154597541232213984L;
?? ?Text2Frame txw = new Text2Frame();
?? ?Text3Frame txw3 = new Text3Frame();
?? ?static JFrame sc = new JFrame();
?? ?static int jishu = 1;
?
?? ?static int summm = 1;
?? ?static int summm2 = 1;
?? ?static int arr[][] = new int[11][12];
?
?? ?int x = 5;
?? ?int y = 5;
?? ?int sum = 0;
?? ?int sum2 = 0;
?? ?Node n1 = new Node(x, y);
?? ?seqlist kai = new seqlist(n1);
?? ?seqlist seq = new seqlist(null);
?? ?seqlist seq2 = new seqlist(null);
?
?? ?static void soushang(int a, int b) {
?
?? ??? ?if (a - 1 < 1) {
?
?? ??? ??? ?return;
?
?? ??? ?}
?? ??? ?if (arr[a - 1][b] == 1 && a - 1 > 0) {
?
?? ??? ??? ?summm++;
?? ??? ??? ?if (summm == 5) {
?? ??? ??? ??? ?for (int i = 0; i < 11; i++) {
?? ??? ??? ??? ??? ?for (int k = 0; k < 12; k++) {
?? ??? ??? ??? ??? ??? ?arr[i][k] = 0;
?? ??? ??? ??? ??? ?}
?
?? ??? ??? ??? ?}
?? ??? ??? ??? ?System.out.println("勝利");
?? ??? ??? ??? ?JOptionPane.showMessageDialog(sc, "紅色方勝利,點(diǎn)擊確定重新開(kāi)始", "結(jié)果", JOptionPane.WARNING_MESSAGE);
?
?? ??? ??? ?}
?
?? ??? ??? ?soushang(a - 1, b);
?
?? ??? ?}
?
?? ?}
?
?? ?static void souxia(int a, int b) {
?
?? ??? ?if (a + 1 > 10) {
?
?? ??? ??? ?return;
?
?? ??? ?}
?? ??? ?if (arr[a + 1][b] == 1 && a + 1 <= 10) {
?
?? ??? ??? ?summm++;
?? ??? ??? ?if (summm == 5) {
?? ??? ??? ??? ?for (int i = 0; i < 11; i++) {
?? ??? ??? ??? ??? ?for (int k = 0; k < 12; k++) {
?? ??? ??? ??? ??? ??? ?arr[i][k] = 0;
?? ??? ??? ??? ??? ?}
?
?? ??? ??? ??? ?}
?? ??? ??? ??? ?System.out.println("勝利");
?? ??? ??? ??? ?JOptionPane.showMessageDialog(sc, "紅色方勝利,點(diǎn)擊確定重新開(kāi)始", "結(jié)果", JOptionPane.WARNING_MESSAGE);
?? ??? ??? ?}
?
?? ??? ??? ?souxia(a + 1, b);
?
?? ??? ?}
?
?? ?}
?
?? ?static void souzuo(int a, int b) {
?
?? ??? ?if (b - 1 < 1) {
?
?? ??? ??? ?return;
?
?? ??? ?}
?? ??? ?if (arr[a][b - 1] == 1 && b - 1 >= 1) {
?
?? ??? ??? ?summm++;
?? ??? ??? ?if (summm == 5) {
?? ??? ??? ??? ?for (int i = 0; i < 11; i++) {
?? ??? ??? ??? ??? ?for (int k = 0; k < 12; k++) {
?? ??? ??? ??? ??? ??? ?arr[i][k] = 0;
?? ??? ??? ??? ??? ?}
?
?? ??? ??? ??? ?}
?? ??? ??? ??? ?System.out.println("勝利");
?? ??? ??? ??? ?JOptionPane.showMessageDialog(sc, "紅色方勝利,點(diǎn)擊確定重新開(kāi)始", "結(jié)果", JOptionPane.WARNING_MESSAGE);
?? ??? ??? ?}
?
?? ??? ??? ?souzuo(a, b - 1);
?
?? ??? ?}
?
?? ?}
?
?? ?static void souyou(int a, int b) {
?
?? ??? ?if (b + 1 > 10) {
?
?? ??? ??? ?return;
?
?? ??? ?}
?? ??? ?if (arr[a][b + 1] == 1 && b + 1 <= 10) {
?
?? ??? ??? ?summm++;
?? ??? ??? ?if (summm == 5) {
?? ??? ??? ??? ?for (int i = 0; i < 11; i++) {
?? ??? ??? ??? ??? ?for (int k = 0; k < 12; k++) {
?? ??? ??? ??? ??? ??? ?arr[i][k] = 0;
?? ??? ??? ??? ??? ?}
?
?? ??? ??? ??? ?}
?? ??? ??? ??? ?System.out.println("勝利");
?? ??? ??? ??? ?JOptionPane.showMessageDialog(sc, "紅色方勝利,點(diǎn)擊確定重新開(kāi)始", "結(jié)果", JOptionPane.WARNING_MESSAGE);
?? ??? ??? ?}
?
?? ??? ??? ?souyou(a, b + 1);
?
?? ??? ?}
?? ?}
?
?? ?static void soushangzuo(int a, int b) {
?
?? ??? ?if (a - 1 < 1 || b - 1 < 1) {
?
?? ??? ??? ?return;
?
?? ??? ?}
?? ??? ?if (arr[a - 1][b - 1] == 1 && (a - 1 > 0) && (b - 1) > 0) {
?
?? ??? ??? ?summm++;
?
?? ??? ??? ?if (summm == 5) {
?? ??? ??? ??? ?for (int i = 0; i < 11; i++) {
?? ??? ??? ??? ??? ?for (int k = 0; k < 12; k++) {
?? ??? ??? ??? ??? ??? ?arr[i][k] = 0;
?? ??? ??? ??? ??? ?}
?
?? ??? ??? ??? ?}
?? ??? ??? ??? ?System.out.println("勝利");
?? ??? ??? ??? ?JOptionPane.showMessageDialog(sc, "紅色方勝利,點(diǎn)擊確定重新開(kāi)始", "結(jié)果", JOptionPane.WARNING_MESSAGE);
?? ??? ??? ?}
?
?? ??? ??? ?soushangzuo(a - 1, b - 1);
?? ??? ?}
?
?? ?}
?
?? ?static void souxiazuo(int a, int b) {
?
?? ??? ?if (a + 1 > 10 || b - 1 < 1) {
?
?? ??? ??? ?return;
?
?? ??? ?}
?? ??? ?if (arr[a + 1][b - 1] == 1 && (a + 1 <= 10) && (b - 1) >= 1) {
?
?? ??? ??? ?summm++;
?? ??? ??? ?if (summm == 5) {
?? ??? ??? ??? ?for (int i = 0; i < 11; i++) {
?? ??? ??? ??? ??? ?for (int k = 0; k < 12; k++) {
?? ??? ??? ??? ??? ??? ?arr[i][k] = 0;
?? ??? ??? ??? ??? ?}
?
?? ??? ??? ??? ?}
?? ??? ??? ??? ?System.out.println("勝利");
?? ??? ??? ??? ?JOptionPane.showMessageDialog(sc, "紅色方勝利,點(diǎn)擊確定重新開(kāi)始", "結(jié)果", JOptionPane.WARNING_MESSAGE);
?? ??? ??? ?}
?
?? ??? ??? ?souxiazuo(a + 1, b - 1);
?? ??? ?}
?
?? ?}
?
?? ?static void souyoushang(int a, int b) {
?
?? ??? ?if (a - 1 < 1 && b + 1 > 10) {
?
?? ??? ??? ?return;
?
?? ??? ?}
?? ??? ?if (arr[a - 1][b + 1] == 1 && a - 1 >= 1 && b + 1 <= 10) {
?
?? ??? ??? ?summm++;
?? ??? ??? ?if (summm == 5) {
?? ??? ??? ??? ?for (int i = 0; i < 11; i++) {
?? ??? ??? ??? ??? ?for (int k = 0; k < 12; k++) {
?? ??? ??? ??? ??? ??? ?arr[i][k] = 0;
?? ??? ??? ??? ??? ?}
?
?? ??? ??? ??? ?}
?? ??? ??? ??? ?System.out.println("勝利");
?? ??? ??? ??? ?JOptionPane.showMessageDialog(sc, "紅色方勝利,點(diǎn)擊確定重新開(kāi)始", "結(jié)果", JOptionPane.WARNING_MESSAGE);
?? ??? ??? ?}
?
?? ??? ??? ?souyoushang(a - 1, b + 1);
?? ??? ?}
?
?? ?}
?
?? ?static void souyouxia(int a, int b) {
?
?? ??? ?if (b + 1 > 10 && a + 1 > 10) {
?
?? ??? ??? ?return;
?
?? ??? ?}
?? ??? ?if (arr[a + 1][b + 1] == 1 && b + 1 <= 10 && a + 1 <= 10) {
?
?? ??? ??? ?summm++;
?? ??? ??? ?if (summm == 5) {
?? ??? ??? ??? ?for (int i = 0; i < 11; i++) {
?? ??? ??? ??? ??? ?for (int k = 0; k < 12; k++) {
?? ??? ??? ??? ??? ??? ?arr[i][k] = 0;
?? ??? ??? ??? ??? ?}
?
?? ??? ??? ??? ?}
?? ??? ??? ??? ?System.out.println("勝利");
?? ??? ??? ??? ?JOptionPane.showMessageDialog(sc, "紅色方勝利,點(diǎn)擊確定重新開(kāi)始", "結(jié)果", JOptionPane.WARNING_MESSAGE);
?? ??? ??? ?}
?
?? ??? ??? ?souyouxia(a + 1, b + 1);
?? ??? ?}
?? ?}
?
?? ?static void soushang2(int a, int b) {
?
?? ??? ?if (a - 1 < 1) {
?
?? ??? ??? ?return;
?
?? ??? ?}
?? ??? ?if (arr[a - 1][b] == 2 && a - 1 > 0) {
?
?? ??? ??? ?summm2++;
?? ??? ??? ?if (summm2 == 5) {
?? ??? ??? ??? ?for (int i = 0; i < 11; i++) {
?? ??? ??? ??? ??? ?for (int k = 0; k < 12; k++) {
?? ??? ??? ??? ??? ??? ?arr[i][k] = 0;
?? ??? ??? ??? ??? ?}
?
?? ??? ??? ??? ?}
?? ??? ??? ??? ?System.out.println("勝利");
?? ??? ??? ??? ?JOptionPane.showMessageDialog(sc, "綠色方勝利,點(diǎn)擊確定重新開(kāi)始", "結(jié)果", JOptionPane.WARNING_MESSAGE);
?? ??? ??? ?}
?
?? ??? ??? ?soushang2(a - 1, b);
?
?? ??? ?}
?
?? ?}
?
?? ?static void souxia2(int a, int b) {
?
?? ??? ?if (a + 1 > 10) {
?
?? ??? ??? ?return;
?
?? ??? ?}
?? ??? ?if (arr[a + 1][b] == 2 && a + 1 <= 10) {
?
?? ??? ??? ?summm2++;
?? ??? ??? ?if (summm2 == 5) {
?? ??? ??? ??? ?for (int i = 0; i < 11; i++) {
?? ??? ??? ??? ??? ?for (int k = 0; k < 12; k++) {
?? ??? ??? ??? ??? ??? ?arr[i][k] = 0;
?? ??? ??? ??? ??? ?}
?
?? ??? ??? ??? ?}
?? ??? ??? ??? ?System.out.println("勝利");
?? ??? ??? ??? ?JOptionPane.showMessageDialog(sc, "綠色方勝利,點(diǎn)擊確定重新開(kāi)始", "結(jié)果", JOptionPane.WARNING_MESSAGE);
?? ??? ??? ?}
?
?? ??? ??? ?souxia2(a + 1, b);
?
?? ??? ?}
?
?? ?}
?
?? ?static void souzuo2(int a, int b) {
?
?? ??? ?if (b - 1 > 10) {
?
?? ??? ??? ?return;
?
?? ??? ?}
?? ??? ?if (arr[a][b - 1] == 2 && b - 1 >= 1) {
?
?? ??? ??? ?summm2++;
?? ??? ??? ?if (summm2 == 5) {
?? ??? ??? ??? ?for (int i = 0; i < 11; i++) {
?? ??? ??? ??? ??? ?for (int k = 0; k < 12; k++) {
?? ??? ??? ??? ??? ??? ?arr[i][k] = 0;
?? ??? ??? ??? ??? ?}
?
?? ??? ??? ??? ?}
?? ??? ??? ??? ?System.out.println("勝利");
?? ??? ??? ??? ?JOptionPane.showMessageDialog(sc, "綠色方勝利,點(diǎn)擊確定重新開(kāi)始", "結(jié)果", JOptionPane.WARNING_MESSAGE);
?? ??? ??? ?}
?
?? ??? ??? ?souzuo2(a, b - 1);
?
?? ??? ?}
?
?? ?}
?
?? ?static void souyou2(int a, int b) {
?
?? ??? ?if (b + 1 > 10) {
?
?? ??? ??? ?return;
?
?? ??? ?}
?? ??? ?if (arr[a][b + 1] == 2 && b + 1 <= 10) {
?
?? ??? ??? ?summm2++;
?? ??? ??? ?if (summm2 == 5) {
?? ??? ??? ??? ?for (int i = 0; i < 11; i++) {
?? ??? ??? ??? ??? ?for (int k = 0; k < 12; k++) {
?? ??? ??? ??? ??? ??? ?arr[i][k] = 0;
?? ??? ??? ??? ??? ?}
?
?? ??? ??? ??? ?}
?? ??? ??? ??? ?System.out.println("勝利");
?? ??? ??? ??? ?JOptionPane.showMessageDialog(sc, "綠色方勝利,點(diǎn)擊確定重新開(kāi)始", "結(jié)果", JOptionPane.WARNING_MESSAGE);
?? ??? ??? ?}
?
?? ??? ??? ?souyou2(a, b + 1);
?
?? ??? ?}
?
?? ?}
?
?? ?static void soushangzuo2(int a, int b) {
?
?? ??? ?if (a - 1 < 1 || b - 1 < 1) {
?
?? ??? ??? ?return;
?
?? ??? ?}
?? ??? ?if (arr[a - 1][b - 1] == 2 && (a - 1 >= 1) && (b - 1) >= 1) {
?
?? ??? ??? ?summm2++;
?
?? ??? ??? ?if (summm2 == 5) {
?? ??? ??? ??? ?for (int i = 0; i < 11; i++) {
?? ??? ??? ??? ??? ?for (int k = 0; k < 12; k++) {
?? ??? ??? ??? ??? ??? ?arr[i][k] = 0;
?? ??? ??? ??? ??? ?}
?
?? ??? ??? ??? ?}
?? ??? ??? ??? ?System.out.println("勝利");
?? ??? ??? ??? ?JOptionPane.showMessageDialog(sc, "綠色方勝利,點(diǎn)擊確定重新開(kāi)始", "結(jié)果", JOptionPane.WARNING_MESSAGE);
?? ??? ??? ?}
?
?? ??? ??? ?soushangzuo2(a - 1, b - 1);
?? ??? ?}
?
?? ?}
?
?? ?static void souxiazuo2(int a, int b) {
?
?? ??? ?if (a + 1 > 10 || b - 1 < 1) {
?
?? ??? ??? ?return;
?
?? ??? ?}
?? ??? ?if (arr[a + 1][b - 1] == 2 && (a + 1 <= 10) && (b - 1) >= 1) {
?
?? ??? ??? ?summm2++;
?? ??? ??? ?if (summm2 == 5) {
?? ??? ??? ??? ?for (int i = 0; i < 11; i++) {
?? ??? ??? ??? ??? ?for (int k = 0; k < 12; k++) {
?? ??? ??? ??? ??? ??? ?arr[i][k] = 0;
?? ??? ??? ??? ??? ?}
?
?? ??? ??? ??? ?}
?? ??? ??? ??? ?System.out.println("勝利");
?? ??? ??? ??? ?JOptionPane.showMessageDialog(sc, "綠色方勝利,點(diǎn)擊確定重新開(kāi)始", "結(jié)果", JOptionPane.WARNING_MESSAGE);
?? ??? ??? ?}
?
?? ??? ??? ?souxiazuo2(a + 1, b - 1);
?? ??? ?}
?
?? ?}
?
?? ?static void souyoushang2(int a, int b) {
?
?? ??? ?if (a - 1 < 1 && b + 1 > 10) {
?
?? ??? ??? ?return;
?
?? ??? ?}
?? ??? ?if (arr[a - 1][b + 1] == 2 && a - 1 >= 1 && b + 1 <= 10) {
?
?? ??? ??? ?summm2++;
?? ??? ??? ?if (summm2 == 5) {
?? ??? ??? ??? ?for (int i = 0; i < 11; i++) {
?? ??? ??? ??? ??? ?for (int k = 0; k < 12; k++) {
?? ??? ??? ??? ??? ??? ?arr[i][k] = 0;
?? ??? ??? ??? ??? ?}
?
?? ??? ??? ??? ?}
?? ??? ??? ??? ?System.out.println("勝利");
?? ??? ??? ??? ?JOptionPane.showMessageDialog(sc, "綠色方勝利,點(diǎn)擊確定重新開(kāi)始", "結(jié)果", JOptionPane.WARNING_MESSAGE);
?? ??? ??? ?}
?
?? ??? ??? ?souyoushang2(a - 1, b + 1);
?? ??? ?}
?
?? ?}
?
?? ?static void souyouxia2(int a, int b) {
?
?? ??? ?if (b + 1 > 10 && a + 1 > 10) {
?
?? ??? ??? ?return;
?
?? ??? ?}
?? ??? ?if (arr[a + 1][b + 1] == 2 && b + 1 <= 10 && a + 1 <= 10) {
?
?? ??? ??? ?summm2++;
?? ??? ??? ?if (summm2 == 5) {
?? ??? ??? ??? ?for (int i = 0; i < 11; i++) {
?? ??? ??? ??? ??? ?for (int k = 0; k < 12; k++) {
?? ??? ??? ??? ??? ??? ?arr[i][k] = 0;
?? ??? ??? ??? ??? ?}
?
?? ??? ??? ??? ?}
?? ??? ??? ??? ?System.out.println("勝利");
?? ??? ??? ??? ?JOptionPane.showMessageDialog(sc, "綠色方勝利,點(diǎn)擊確定重新開(kāi)始", "結(jié)果", JOptionPane.WARNING_MESSAGE);
?? ??? ??? ?}
?
?? ??? ??? ?souyouxia2(a + 1, b + 1);
?? ??? ?}
?? ?}
?
?? ?public void paint(Graphics g) {
?? ??? ?if (jishu % 2 == 1) {
?? ??? ??? ?String aaa = "紅方開(kāi)始下棋";
?? ??? ??? ?txw.add(aaa);
?
?? ??? ?} else {
?? ??? ??? ?String aaa = "綠方開(kāi)始下棋";
?? ??? ??? ?txw.add(aaa);
?
?? ??? ?}
?
?? ??? ?txw3.add(txw3.shu(x, y));
?? ??? ?super.paint(g);
?? ??? ?for (int i = 1; i <= 10; i++) {
?? ??? ??? ?for (int k = 1; k <= 10; k++) {
?? ??? ??? ??? ?g.fillOval((i - 1) * 50, (k - 1) * 50, 50, 50);
?? ??? ??? ?}
?? ??? ?}
?? ??? ?Color c = g.getColor();
?
?? ??? ?g.fillOval(x * 50, y * 50, 50, 50);
?? ??? ?Node now = seq.head;
?? ??? ?Node tou = kai.head;
?? ??? ?Color u = g.getColor();
?? ??? ?if (jishu % 2 == 1) {
?? ??? ??? ?g.setColor(Color.red);
?? ??? ??? ?g.fillOval((tou.a - 1) * 50, (tou.b - 1) * 50, 50, 50);
?? ??? ??? ?g.setColor(u);
?? ??? ?} else {
?? ??? ??? ?g.setColor(Color.green);
?? ??? ??? ?g.fillOval((tou.a - 1) * 50, (tou.b - 1) * 50, 50, 50);
?? ??? ??? ?g.setColor(u);
?
?? ??? ?}
?
?? ??? ?while (now != null) {
?? ??? ??? ?System.out.print("(" + now.a + " " + now.b + ")");
?? ??? ??? ?Color r = g.getColor();
?? ??? ??? ?g.setColor(Color.red);
?? ??? ??? ?g.fillOval((now.a - 1) * 50, (now.b - 1) * 50, 50, 50);
?? ??? ??? ?g.setColor(r);
?? ??? ??? ?now = now.next;
?
?? ??? ?}
?? ??? ?Node now2 = seq2.head;
?? ??? ?while (now2 != null) {
?? ??? ??? ?System.out.print("(" + now2.a + " " + now2.b + ")");
?? ??? ??? ?Color r = g.getColor();
?? ??? ??? ?g.setColor(Color.green);
?? ??? ??? ?g.fillOval((now2.a - 1) * 50, (now2.b - 1) * 50, 50, 50);
?? ??? ??? ?g.setColor(r);
?? ??? ??? ?now2 = now2.next;
?
?? ??? ?}
?? ??? ?System.out.println();
?? ?}
?
?? ?// 鍵的一個(gè)值被輸出
?? ?@Override
?? ?public void keyTyped(KeyEvent e) {
?
?? ?}
?
?? ?// 鍵被按下
?? ?@Override
?
?? ?public void keyPressed(KeyEvent e) {
?
?? ??? ?System.out.print("線性表為");
?
?? ??? ?System.out.println();
?? ??? ?// System.out.println("鍵被按下"+e.getKeyCode());
?? ??? ?if (e.getKeyCode() == KeyEvent.VK_DOWN) {
?
?? ??? ??? ?// System.out.println("12");
?
?? ??? ??? ?y = y + 1;
?? ??? ??? ?if (y >= 11) {
?? ??? ??? ??? ?y = y % 11 + 1;
?? ??? ??? ?}
?
?? ??? ?} else if (e.getKeyCode() == KeyEvent.VK_UP) {
?? ??? ??? ?y = y - 1;
?? ??? ??? ?if (y < 1) {
?? ??? ??? ??? ?y = y + 10;
?? ??? ??? ?}
?
?? ??? ?} else if (e.getKeyCode() == KeyEvent.VK_LEFT) {
?? ??? ??? ?x = x - 1;
?? ??? ??? ?if (x < 1) {
?? ??? ??? ??? ?x = x + 10;
?? ??? ??? ?}
?? ??? ?} else if (e.getKeyCode() == KeyEvent.VK_RIGHT) {
?
?? ??? ??? ?x = x + 1;
?? ??? ??? ?if (x >= 11) {
?? ??? ??? ??? ?x = x % 11 + 1;
?? ??? ??? ?}
?
?? ??? ?} else if (e.getKeyCode() == KeyEvent.VK_SPACE) {
?? ??? ??? ?int luo1 = x;
?? ??? ??? ?int luo2 = y;
?
?? ??? ??? ?Node n2 = new Node(luo1, luo2);
?? ??? ??? ?if (jishu % 2 != 0) {
?? ??? ??? ??? ?Node now3 = seq2.head;
?? ??? ??? ??? ?Node now2 = seq.head;
?? ??? ??? ??? ?int aaa = 1;
?
?? ??? ??? ??? ?if (arr[x][y] == 1 || arr[x][y] == 2) {
?? ??? ??? ??? ??? ?JOptionPane.showMessageDialog(sc, "此處已有棋子,請(qǐng)下別處", "錯(cuò)誤", JOptionPane.WARNING_MESSAGE);
?? ??? ??? ??? ??? ?aaa = 2;
?
?? ??? ??? ??? ?}
?
?? ??? ??? ??? ?if (aaa == 1) {
?
?? ??? ??? ??? ??? ?jishu++;
?? ??? ??? ??? ??? ?seq.add(n2);
?? ??? ??? ??? ??? ?arr[luo1][luo2] = 1;
?? ??? ??? ??? ??? ?seq.tostring();
?? ??? ??? ??? ??? ?System.out.println("摁下空格");
?? ??? ??? ??? ??? ?soushang(x, y);
?
?? ??? ??? ??? ??? ?System.out.println("sum1" + " ?" + summm);
?? ??? ??? ??? ??? ?if (summm == 5) {
?? ??? ??? ??? ??? ??? ?seq.head = null;
?? ??? ??? ??? ??? ??? ?seq2.head = null;
?? ??? ??? ??? ??? ?}
?
?? ??? ??? ??? ??? ?souxia(x, y);
?? ??? ??? ??? ??? ?System.out.println("sum2" + " ?" + summm);
?? ??? ??? ??? ??? ?if (summm == 5) {
?? ??? ??? ??? ??? ??? ?seq.head = null;
?? ??? ??? ??? ??? ??? ?seq2.head = null;
?? ??? ??? ??? ??? ?}
?? ??? ??? ??? ??? ?summm = 1;
?? ??? ??? ??? ??? ?souzuo(x, y);
?? ??? ??? ??? ??? ?System.out.println("sum3" + " ?" + summm);
?? ??? ??? ??? ??? ?if (summm == 5) {
?? ??? ??? ??? ??? ??? ?seq.head = null;
?? ??? ??? ??? ??? ??? ?seq2.head = null;
?? ??? ??? ??? ??? ?}
?
?? ??? ??? ??? ??? ?souyou(x, y);
?? ??? ??? ??? ??? ?System.out.println("sum4" + " ?" + summm);
?? ??? ??? ??? ??? ?if (summm == 5) {
?? ??? ??? ??? ??? ??? ?seq.head = null;
?? ??? ??? ??? ??? ??? ?seq2.head = null;
?? ??? ??? ??? ??? ?}
?? ??? ??? ??? ??? ?summm = 1;
?
?? ??? ??? ??? ??? ?soushangzuo(x, y);
?? ??? ??? ??? ??? ?System.out.println("sum5" + " ?" + summm);
?? ??? ??? ??? ??? ?if (summm == 5) {
?? ??? ??? ??? ??? ??? ?seq.head = null;
?? ??? ??? ??? ??? ??? ?seq2.head = null;
?? ??? ??? ??? ??? ?}
?
?? ??? ??? ??? ??? ?souyouxia(x, y);
?? ??? ??? ??? ??? ?System.out.println("sum6" + " ?" + summm);
?? ??? ??? ??? ??? ?if (summm == 5) {
?? ??? ??? ??? ??? ??? ?seq.head = null;
?? ??? ??? ??? ??? ??? ?seq2.head = null;
?? ??? ??? ??? ??? ?}
?? ??? ??? ??? ??? ?summm = 1;
?? ??? ??? ??? ??? ?souyoushang(x, y);
?? ??? ??? ??? ??? ?System.out.println("sum7" + " ?" + summm);
?? ??? ??? ??? ??? ?if (summm == 5) {
?? ??? ??? ??? ??? ??? ?seq.head = null;
?? ??? ??? ??? ??? ??? ?seq2.head = null;
?? ??? ??? ??? ??? ?}
?? ??? ??? ??? ??? ?souxiazuo(x, y);
?? ??? ??? ??? ??? ?if (summm == 5) {
?? ??? ??? ??? ??? ??? ?seq.head = null;
?? ??? ??? ??? ??? ??? ?seq2.head = null;
?? ??? ??? ??? ??? ?}
?? ??? ??? ??? ??? ?summm = 1;
?? ??? ??? ??? ?}
?
?? ??? ??? ?} else {
?? ??? ??? ??? ?int aaa = 1;
?
?? ??? ??? ??? ?if (arr[x][y] == 1 || arr[x][y] == 2) {
?? ??? ??? ??? ??? ?JOptionPane.showMessageDialog(sc, "此處已有棋子,請(qǐng)下別處", "錯(cuò)誤", JOptionPane.WARNING_MESSAGE);
?? ??? ??? ??? ??? ?aaa = 2;
?
?? ??? ??? ??? ?}
?? ??? ??? ??? ?if (aaa == 1) {
?
?? ??? ??? ??? ??? ?jishu++;
?? ??? ??? ??? ??? ?seq2.add(n2);
?? ??? ??? ??? ??? ?arr[luo1][luo2] = 2;
?? ??? ??? ??? ??? ?seq2.tostring();
?? ??? ??? ??? ??? ?System.out.println("摁下空格");
?? ??? ??? ??? ??? ?soushang2(x, y);
?
?? ??? ??? ??? ??? ?System.out.println("sum1" + " ?" + summm);
?? ??? ??? ??? ??? ?if (summm2 == 5) {
?? ??? ??? ??? ??? ??? ?seq.head = null;
?? ??? ??? ??? ??? ??? ?seq2.head = null;
?? ??? ??? ??? ??? ?}
?
?? ??? ??? ??? ??? ?souxia2(x, y);
?? ??? ??? ??? ??? ?System.out.println("sum2" + " ?" + summm);
?? ??? ??? ??? ??? ?if (summm2 == 5) {
?? ??? ??? ??? ??? ??? ?seq.head = null;
?? ??? ??? ??? ??? ??? ?seq2.head = null;
?? ??? ??? ??? ??? ?}
?? ??? ??? ??? ??? ?summm2 = 1;
?? ??? ??? ??? ??? ?souzuo2(x, y);
?? ??? ??? ??? ??? ?System.out.println("sum3" + " ?" + summm);
?? ??? ??? ??? ??? ?if (summm2 == 5) {
?? ??? ??? ??? ??? ??? ?seq.head = null;
?? ??? ??? ??? ??? ??? ?seq2.head = null;
?? ??? ??? ??? ??? ?}
?
?? ??? ??? ??? ??? ?souyou2(x, y);
?? ??? ??? ??? ??? ?System.out.println("sum4" + " ?" + summm);
?? ??? ??? ??? ??? ?if (summm2 == 5) {
?? ??? ??? ??? ??? ??? ?seq.head = null;
?? ??? ??? ??? ??? ??? ?seq2.head = null;
?? ??? ??? ??? ??? ?}
?? ??? ??? ??? ??? ?summm2 = 1;
?
?? ??? ??? ??? ??? ?soushangzuo2(x, y);
?? ??? ??? ??? ??? ?System.out.println("sum5" + " ?" + summm);
?? ??? ??? ??? ??? ?if (summm2 == 5) {
?? ??? ??? ??? ??? ??? ?seq.head = null;
?? ??? ??? ??? ??? ??? ?seq2.head = null;
?? ??? ??? ??? ??? ?}
?
?? ??? ??? ??? ??? ?souyouxia2(x, y);
?? ??? ??? ??? ??? ?System.out.println("sum6" + " ?" + summm);
?? ??? ??? ??? ??? ?if (summm2 == 5) {
?? ??? ??? ??? ??? ??? ?seq.head = null;
?? ??? ??? ??? ??? ??? ?seq2.head = null;
?? ??? ??? ??? ??? ?}
?? ??? ??? ??? ??? ?summm2 = 1;
?? ??? ??? ??? ??? ?souyoushang2(x, y);
?? ??? ??? ??? ??? ?System.out.println("sum7" + " ?" + summm);
?? ??? ??? ??? ??? ?if (summm2 == 5) {
?? ??? ??? ??? ??? ??? ?seq.head = null;
?? ??? ??? ??? ??? ??? ?seq2.head = null;
?? ??? ??? ??? ??? ?}
?? ??? ??? ??? ??? ?souxiazuo2(x, y);
?? ??? ??? ??? ??? ?if (summm2 == 5) {
?? ??? ??? ??? ??? ??? ?seq.head = null;
?? ??? ??? ??? ??? ??? ?seq2.head = null;
?? ??? ??? ??? ??? ?}
?? ??? ??? ??? ??? ?summm2 = 1;
?
?? ??? ??? ??? ?}
?? ??? ??? ?}
?? ??? ??? ?for (int i = 1; i <= 10; i++) {
?? ??? ??? ??? ?for (int k = 1; k <= 10; k++) {
?? ??? ??? ??? ??? ?System.out.print(arr[i][k] + " ");
?
?? ??? ??? ??? ?}
?? ??? ??? ??? ?System.out.println();
?
?? ??? ??? ?}
?
?? ??? ?}
?? ??? ?kai.huan(x, y);
?
?? ??? ?// 調(diào)用repaint()函數(shù),來(lái)重繪界面
?? ??? ?this.repaint();
?? ?}
?
?? ?class Node {// 設(shè)置 節(jié)點(diǎn)類
?? ??? ?int a;
?? ??? ?int b;
?? ??? ?Node next;
?
?? ??? ?Node(int a, int b) {
?? ??? ??? ?this.a = a;
?? ??? ??? ?this.b = b;
?? ??? ??? ?this.next = null;
?? ??? ?}
?
?? ?}
?
?? ?class seqlist {// 設(shè)置鏈表類
?? ??? ?Node head;
?? ??? ?Node tail;
?
?? ??? ?int n = 0;
?
?? ??? ?public seqlist(Node head) {
?? ??? ??? ?// TODO Auto-generated constructor stub
?? ??? ??? ?this.head = head;
?? ??? ??? ?this.tail = head;
?? ??? ??? ?n++;
?? ??? ?}
?
?? ??? ?void add(Node p) {
?? ??? ??? ?Node now = head;
?? ??? ??? ?p.next = now;
?? ??? ??? ?head = p;
?? ??? ??? ?n++;
?
?? ??? ?}
?
?? ??? ?void tostring() {
?? ??? ??? ?Node now = head;
?? ??? ??? ?System.out.print("線性表為");
?? ??? ??? ?while (now != null) {
?? ??? ??? ??? ?System.out.print(now.a + ",");
?? ??? ??? ??? ?now = now.next;
?? ??? ??? ?}
?? ??? ??? ?System.out.println();
?
?? ??? ?}
?
?? ??? ?int length() {
?? ??? ??? ?return n;
?
?? ??? ?}
?
?? ??? ?void insert(int a, Node b) {
?? ??? ??? ?Node now1 = head;
?? ??? ??? ?for (int i = 0; i < a - 1; i++) {
?? ??? ??? ??? ?now1 = now1.next;
?? ??? ??? ?}
?? ??? ??? ?b.next = now1.next;
?? ??? ??? ?now1.next = b;
?? ??? ??? ?n++;
?? ??? ?}
?
?? ??? ?void delete(int a) {
?? ??? ??? ?Node now1 = head;
?? ??? ??? ?for (int i = 0; i < a - 1; i++) {
?? ??? ??? ??? ?now1 = now1.next;
?? ??? ??? ?}
?? ??? ??? ?now1.next = now1.next.next;
?? ??? ??? ?n--;
?
?? ??? ?}
?
?? ??? ?int geta(int n) {
?? ??? ??? ?Node now1 = head;
?? ??? ??? ?for (int i = 0; i < n - 1; i++) {
?? ??? ??? ??? ?now1 = now1.next;
?
?? ??? ??? ?}
?? ??? ??? ?return now1.a;
?
?? ??? ?}
?
?? ??? ?void huan(int a, int b) {
?? ??? ??? ?head.a = a;
?? ??? ??? ?head.b = b;
?
?? ??? ?}
?
?? ??? ?int getb(int n) {
?? ??? ??? ?Node now1 = head;
?? ??? ??? ?for (int i = 0; i < n - 1; i++) {
?? ??? ??? ??? ?now1 = now1.next;
?
?? ??? ??? ?}
?? ??? ??? ?return now1.b;
?
?? ??? ?}
?
?? ?}
?
?? ?// 鍵被釋放
?? ?@Override
?? ?public void keyReleased(KeyEvent e) {
?? ?}
}

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • 聊聊finally中的代碼一定會(huì)執(zhí)行嗎

    聊聊finally中的代碼一定會(huì)執(zhí)行嗎

    通常在面試中,只要是疑問(wèn)句一般答案都是“否定”的,因?yàn)槿绻恰按_定”和“正常”的,那面試官就沒(méi)有必要再問(wèn)了嘛,本文想和大家聊聊finally中的代碼一定會(huì)執(zhí)行嗎?,感興趣的朋友跟著小編一起來(lái)看看吧
    2023-12-12
  • Spring Security 控制授權(quán)的方法

    Spring Security 控制授權(quán)的方法

    本篇文章主要介紹了Spring Security 控制授權(quán)的方法,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2018-02-02
  • Java工程使用ffmpeg進(jìn)行音視頻格式轉(zhuǎn)換的實(shí)現(xiàn)

    Java工程使用ffmpeg進(jìn)行音視頻格式轉(zhuǎn)換的實(shí)現(xiàn)

    FFmpeg是一套可以用來(lái)記錄、轉(zhuǎn)換數(shù)字音頻、視頻,并能將其轉(zhuǎn)化為流的開(kāi)源計(jì)算機(jī)程序,本文主要介紹了Java工程使用ffmpeg進(jìn)行音視頻格式轉(zhuǎn)換的實(shí)現(xiàn)
    2024-02-02
  • Java中-Xms和-Xmx參數(shù)的使用與默認(rèn)內(nèi)存設(shè)置

    Java中-Xms和-Xmx參數(shù)的使用與默認(rèn)內(nèi)存設(shè)置

    在 Java 程序運(yùn)行時(shí),內(nèi)存的管理是影響程序性能的關(guān)鍵因素之一,Java 程序使用的內(nèi)存主要由兩部分組成:堆內(nèi)存和棧內(nèi)存,Java 提供了多個(gè)參數(shù)來(lái)控制堆內(nèi)存的大小,其中最常用的參數(shù)是 -Xms 和 -Xmx,本文將詳細(xì)介紹這些參數(shù),需要的朋友可以參考下
    2024-11-11
  • MyBatis-Plus 批量保存的操作方法

    MyBatis-Plus 批量保存的操作方法

    在項(xiàng)目開(kāi)發(fā)中,需要插入批量插入20多萬(wàn)條數(shù)據(jù),通過(guò)日志觀察,發(fā)現(xiàn)在調(diào)用MyBatis-Plus中的saveBatch()方法性能非常的差,本篇文章主要分享一下saveBatch()的原理以及使用的注意事項(xiàng),感興趣的朋友跟隨小編一起看看吧
    2024-01-01
  • MyBatis insert操作插入數(shù)據(jù)之后返回插入記錄的id

    MyBatis insert操作插入數(shù)據(jù)之后返回插入記錄的id

    今天小編就為大家分享一篇關(guān)于MyBatis插入數(shù)據(jù)之后返回插入記錄的id,小編覺(jué)得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來(lái)看看吧
    2019-03-03
  • java實(shí)現(xiàn)文件上傳到服務(wù)器

    java實(shí)現(xiàn)文件上傳到服務(wù)器

    這篇文章主要為大家詳細(xì)介紹了java實(shí)現(xiàn)文件上傳到服務(wù)器,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-06-06
  • java多線程編程之使用runnable接口創(chuàng)建線程

    java多線程編程之使用runnable接口創(chuàng)建線程

    實(shí)現(xiàn)Runnable接口的類必須使用Thread類的實(shí)例才能創(chuàng)建線程,通過(guò)Runnable接口創(chuàng)建線程分為以下兩步
    2014-01-01
  • Gateway網(wǎng)關(guān)源碼解析

    Gateway網(wǎng)關(guān)源碼解析

    這篇文章主要介紹了Gateway微服務(wù)網(wǎng)關(guān),負(fù)載均衡,熔斷和限流,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-07-07
  • Java封裝實(shí)現(xiàn)自適應(yīng)的單位轉(zhuǎn)換工具類

    Java封裝實(shí)現(xiàn)自適應(yīng)的單位轉(zhuǎn)換工具類

    這篇文章主要為大家詳細(xì)介紹了如何使用Java封裝實(shí)現(xiàn)一個(gè)自適應(yīng)的單位轉(zhuǎn)換工具類,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下
    2025-03-03

最新評(píng)論

绍兴市| 沐川县| 台南市| 恩施市| 廊坊市| 罗源县| 崇仁县| 名山县| 华池县| 伊宁县| 金溪县| 寿光市| 揭阳市| 彭州市| 九龙坡区| 苗栗县| 周至县| 弥勒县| 平武县| 陆川县| 永胜县| 镇安县| 荣昌县| 阳新县| 杂多县| 沧源| 独山县| 玉林市| 井研县| 瑞昌市| 灌南县| 台东县| 汕头市| 蓬溪县| 虎林市| 曲阳县| 衡南县| 大化| 博罗县| 磴口县| 怀集县|