database.java

来自「This code is to estimate the parameter o」· Java 代码 · 共 56 行

JAVA
56
字号
import java.awt.*;class Database {  final int maxnp = 1024;  final int PtSize = 5;  int[] x = new int[maxnp];  int[] y = new int[maxnp];  int np;  int xsiz, ysiz;  Color col;  boolean lockflag = false;  public Database(int xSize, int ySize, Color Col) {    xsiz = xSize;    ysiz = ySize;    col = Col;    np = 0;  }    public void paint(Graphics g) {    g.setColor(col);    for(int i = 0; i < np; i++) {      g.fillRect(x[i]-PtSize/2,y[i]-PtSize/2,PtSize,PtSize);    }   }  public void push(int newx, int newy) {    if(np < maxnp) {      x[np] = newx;      y[np] = newy;      np++;    }  }  public void clearPoints() {    np = 0;  }  public void randomPoints(int n) {    for(int i = 0; i < n; i++)      push((int) (xsiz * Math.random()), (int) (ysiz * Math.random()));  }  public int nPoints() {    return np;  }  public int xVal(int i) {    return x[i];  }  public int yVal(int i) {    return y[i];  }}

⌨️ 快捷键说明

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