oval.java

来自「这是一种用JAVA开发的图形画法程序 没有错误 欢迎各位朋友改进并上传」· Java 代码 · 共 43 行

JAVA
43
字号
/**
 * Title: Oval.java
 * Description: Classes that define an Oval  
 * It should be subclasses of GeometricShape and include the implementation of two methods
 * named calculateArea and calculatePerimeter.
 * 
 * Copyright: Copyright (c) 2006
 * @author Q Jin
 * @version 1.0
 */

public class Oval extends GeometricShape{
	
	// this is a default oval method
	public Oval(){
		this(0,0);
	}
	
	// this is a oval method with two parameters
	public Oval( int x, int y ){
		this.x = x;
		this.y = y;
	}
	
	/**
	 * This is calculateArea method
	 * 
	 * @return Math.PI * x * x / 4    this is area of shapes
	 */ 
	public double calculateArea(){
		return Math.PI * x * x / 4;
	}
	
	/**
	 * This is a calculatePerimeter method
	 * 
	 * @return Math.PI * x  this is perimeter of shapes
	 */
	public double calculatePerimeter(){
		return Math.PI * x;
	}
	
}

⌨️ 快捷键说明

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