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

📄 rec2.java

📁 清华大学的java教程
💻 JAVA
字号:
interface Shape
{
	public void getArea();
	public void getCircumference();
	public void noUse();
}

interface Color
{
	public void getColor();
}

class Rectangle implements Shape,Color
{
	private int x,y;
	private double width,height;
	String color;
	
	Rectangle()
	{
		x=0;
		y=0;
	}
	
	Rectangle(double w,double h,String c)
	{
		width=w;
		height=h;
		color=c;
	}
	
	public double getWidth()
	{  return width;  }
	
	public double getHeight()
	{  return height;  }
		
	public void setWidth(double width)
	{
		this.width=width;
	}
	
	public void setHeight(double height)
	{
		this.height=height;
	}
	
	public void setColor(String color)
	{
		this.color=color;
	}
	
	public void getArea()
	{
		System.out.println("The Area is "+width*height+"\n");
	}
	
	public void getCircumference()	
	{
		System.out.println("The Circumference is "+2*(width+height)+"\n");
	}
	
	public void getColor()
	{
		System.out.println("The color is "+color+"\n");
	}
	
	public void noUse() {}
}

public class Rec2
{
	public static void main(String[] args)
	{
		Rectangle r=new Rectangle(5,6,"Red");
		r.getColor();
		r.getArea();
		r.getCircumference();	
	}
}

⌨️ 快捷键说明

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