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

📄 second.java

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

interface Color
{
	void getColor();
}

class Rectangle1 implements Shape,Color
{
	private int x,y;
	private double width,height;
	String color;
	
	Rectangle1()
	{
		x=0;
		y=0;
		width=0;
		height=0;
		color="红";
	}
	
	Rectangle1(double width,double height,String color)
	{
		this.width=width;
		this.height=height;
		this.color=color;
	}
	
	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 second
{
	public static void main(String[] args)
	{
		Rectangle1 R=new Rectangle1(3,4,"红");
		R.getColor();
		R.getArea();
		R.getCircumference();
	}
}

⌨️ 快捷键说明

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