⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 interfaceexample.java

📁 Java程序设计实验与实训源代码经典的JAVA学习教材
💻 JAVA
字号:
interface Area 
{
float calculateArea();
}
class Circle implements Area
{
	 private float x;
	 private float y;
	 private float radius;
	 
	 Circle(float x ,float y,float radius) 
	 {
	 	this.x=x;
	 	this.y=y;
	 	this. radius=radius;
	 }
	 public float calculateArea() 
	 {
	 	return((float)Math. PI*radius*radius);
	 }
}
class Rectangle 
{
	private float width ;
	private float height;
	Rectangle(float width,float height)
	{ 
	   this.width=width;
	   this.height=height;
    }
    
     public float calculateArea() 
     {
     	return(width*height);
     }
   }
   public class InterfaceExample
   {
   	public static void main(String[] args)
   	{
   		Circle c=new Circle(3,4,8);
   		System.out.println("Crcle's area="+c.calculateArea());
   		Rectangle r=new Rectangle(4,6);
   		System.out.println("Rectangle's area="+r.calculateArea());
    }
   }
 

⌨️ 快捷键说明

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