geometricshape.java

来自「此程序可实现:在可视化界面中随即生成一些图形(长方形、椭圆、圆、正方形);程序会」· Java 代码 · 共 45 行

JAVA
45
字号
import java.util.ArrayList;

/**
 * A superclass to define Geometric Shape.
 * 
 * @author Ruixiao Wu.
 * @version 1.0 26/06/2006.
 */
public abstract class GeometricShape {

	/**
	 * An abstract class to define the geometric shapes.
	 */

	

	/**
	 * An method to creat random parameter of geometric shapes.
	 * 
	 * @param numOfRandom,maxRange.
	 */
	public ArrayList<Integer> randomNum(int numOfRandom, int maxRange) {
		ArrayList<Integer> numList = new ArrayList<Integer>();
		int j;		
		for (int i = 0; i < numOfRandom; ++i) {
			j = (int) (Math.random() * maxRange + 1);
			numList.add(j);
		}
		return numList;
	}

	/**
	 * An abstract method to caculate the shapes' area.
	 
	 */
	abstract void calculateArea();

	/**
	 * An abstract method to caculate the shapes' perimeter.
	 
	 */
	abstract void calculatePerimeter();

}

⌨️ 快捷键说明

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