main.java

来自「Maze solving using java」· Java 代码 · 共 52 行

JAVA
52
字号
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package maze;import java.io.FileNotFoundException;import java.util.Random;import javax.swing.JOptionPane;/** * * @author James Bond 007 */public class main {    @SuppressWarnings("static-access")    public static void main(String[] args) throws FileNotFoundException {        String mazew = JOptionPane.showInputDialog("Input maze width","10");    String mazeh = JOptionPane.showInputDialog("Input maze height","10");    int w = new Integer(mazew);    int h = new Integer(mazeh);    int[][] map = new int[h][w];    int startx = 0;    int starty = 0;    int goalx = 0;    int goaly = 0;    while (goalx == 0 && goaly == 0) {        goalx = new Random().nextInt(h);        goaly = new Random().nextInt(w);    }    for (int i = 0; i < h; i++)        for (int j = 0; j < w; j++) {            map[i][j]=new Random().nextInt(1);        }    Maze maze = new Maze(h, w, map, startx, starty, goalx, goaly);                if(JOptionPane.showInputDialog("Select mode to start: G for Graphic, C for console mode (Text mode)", "G").equals("G")){                java.awt.EventQueue.invokeLater(new Runnable() {                    public void run() {                        new frmmaze().setVisible(true);                    }                });            }else{                new RunMaze().main(args);            }	}}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?