java注释测试题
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
java注释测试题
Java源代码原题,加注释
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Font;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.util.Arrays;
import javax.swing.JApplet;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class Billard4K extends JPanel implements Runnable, MouseListener, MouseMotionListener {
// GAME STA TES
public final int WAITING_TO_START = 0;
public final int WAITING_TO_HIT = 1;
public final int MOVING = 2;
public final int FINISHING = 3;
public int state = 0;
// TABLE
double hR;
double[] tableX;
double[] tableY;
double[] holesX;
double[] holesY;
// BALLS
public int nballs;
public int nBallsOn;
double[] x;
double[] y;
double[] vx;
double[] vy;
double[] nextX;
double[] nextY;
double[] nextVx;
double[] nextVy;
boolean[] borderCollision;
boolean[][] collision;
boolean[] onTable;
double r = 10;
// RENDERING
Image backBuffer;
Image backGround;
// MOUSE
int mX;
int mY;
int mXPost;
int mYPost;
boolean clicked;
// STICK
public final int MAX_STRENGTH = 1000;
int sL = 300;
int actualStep = 0;
public Billard4K() {
super();
this.setBounds(50, 50, 700, 350);
//this.setResizable(false);
//this.setUndecorated(true);
//this.setVisible(true);
JFrame f = new JFrame("Billard4K");
f.add(this);
f.setBounds(0, 0, 700, 380);
f.setResizable(false);
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.requestFocus();
init();
}
public void init() {
initTable();
initBalls();
backBuffer = this.createImage(this.getWidth(), this.getHeight());
//gBackBuffer = backBuffer.getGraphics();
//gBackBuffer.setFont(new Font("Courier", Font.BOLD, 20));
createBackGround();
this.addMouseListener(this);
this.addMouseMotionListener(this);
start();
}
答案
这个代码是javaswing里面很常见的代码结构
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Font;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowListener;
import java.util.Arrays;
import javax.swing.JApplet;
import javax.swing.JFrame;
import javax.swing.JPanel;
public class Billard4K extends JPanel implements Runnable, MouseListener,