hihihahiho 2017-09-21 14:36 采纳率: 0%
浏览 895

简单的java棋盘程序出了问题,小白求解答

import javax.swing.*;
import java.awt.*;

class wq
{

    static int left = 10;
    static int top = 10;
    static int width = 20;
    static int num = 19;
    static Draw d;
    static int qp [][]=new int [19][19];
    static int color=1;

public void showQp()
    {
        for(int i=0;i<num;i++)
        for(int j=0;j<num;j++)
        {
            if(qp[i][j]==1)
        d.drawCircle(left + i*width,top+j*width,8,Color.black);
            if(qp[i][j]==2)
        d.drawCircle(left + i*width,top+j*width,8,Color.white);
        }
    }

//d.drawLine(0 ,0 ,100 ,100);
public void showBoard()
{
for(int i=0; i<num; i++)
{
int w=1;
if(i==0||i==num-1)w=2;
d.drawLine(left,top+i*width,left+width*(num-1),top+i*width,1);
d.drawLine(left+i*width,top,left+i*width,top+width*(num-1),1);

}

        for(int i=3;i<=15;i+=6)
        for(int j=3;j<=15;j+=6)
        d.drawCircle(left+3*width,top+3*width,4,Color.black);
}  

public static void main(String args[])
{
Draw d=new Draw();
{
public void mouseDown(int dx,int dy);
{
showBoard();
}

    };

}

}

  • 写回答

1条回答

  • Buddhist 2017-09-22 06:51
    关注

    你看下这个是否正确?

    public void showQp() { for(int i=0;i

    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料