📄 hw4_819.java
字号:
import java.applet.Applet;import java.awt.Graphics;// create a new applet classpublic class hw4_819 extends Applet{ private static final int NUM_OF_SHAPES = 5; int width, height; MyLine line[] = new MyLine[NUM_OF_SHAPES]; MyRect rectangle[] = new MyRect[NUM_OF_SHAPES]; MyOval oval[] = new MyOval[NUM_OF_SHAPES]; public void init() { width = getSize().width; height = getSize().height; } public void start() { int x, y; for (int i = 0; i < NUM_OF_SHAPES; i++) { line[i] = new MyLine( (int) (Math.random()*width)+1, (int) (Math.random()*height)+1, (int) (Math.random()*width)+1, (int) (Math.random()*height)+1); x = (int) (Math.random()*width) + 1; y = (int) (Math.random()*height) + 1; rectangle[i] = new MyRect( x, y, (int)(Math.random()*(width-x-1))+1, (int)(Math.random()*(height-y-1))+1); x = (int) (Math.random()*width) + 1; y = (int) (Math.random()*height) + 1; oval[i] = new MyOval( x, y, (int)(Math.random()*(width-x-1))+1, (int)(Math.random()*(height-y-1))+1); } } // override the default null paint method public void paint(Graphics g) { for (int i = 0; i < line.length; i++) line[i].draw(g); for (int i = 0; i < rectangle.length; i++) rectangle[i].draw(g); for (int i = 0; i < oval.length; i++) oval[i].draw(g); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -