bricks.java
来自「书籍"Java_面向事件编程"的附带光盘代码」· Java 代码 · 共 32 行
JAVA
32 行
import objectdraw.*;import java.awt.*;// Class that draws bricks and a moonpublic class Bricks extends WindowController { // position and radius of the moon private static final int MOON_INSET = 50; private static final int MOON_SIZE = 70; // dimensions of a brick private static final double BRICK_HEIGHT = 15 ; private static final double BRICK_WIDTH = 30; // level and spacing of bricks private static final double BRICK_TOP = 285; private static final double BRICK_SPACING = 3; public void begin() { // draw the moon new FilledOval(MOON_INSET,MOON_INSET,MOON_SIZE,MOON_SIZE,canvas); // draw bricks along the bottom of the canvas double brickPosition = 0; // x coordinate of the next brick while ( brickPosition < canvas.getWidth() ) { new FilledRect(brickPosition, BRICK_TOP, BRICK_WIDTH, BRICK_HEIGHT,canvas); brickPosition = brickPosition + BRICK_WIDTH + BRICK_SPACING; } }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?