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

📄 java.txt

📁 矩形的面积计算(包括正方形) 矩形的面积计算(包括正方形)矩形的面积计算( 包括正方形) 矩形的面积计算( 包括正方形)
💻 TXT
字号:
public class Rectangle {
	protected double length=0,circulme=0,width=0,area=0;
	public Rectangle()
	{
		length=0;
		width=0;
	}
	public Rectangle(double length,double width)
	{
		this.length=length;
		this.width=width;
		circulme=2*(length+width);
		area=length*width;
		
	}
	void SetRectangle(double length,double width)
	{
		this.length=length;
		this.width=width;
		circulme=2*(length+width);
		area=length*width;
	}
	double GetCirculme()
	{
		return circulme;
	}
	double GetArea()
	{
		return area;
	}
}





import javax.swing.JOptionPane;

public class TestRectangle {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自动生成方法存根
		/*double width=0,length=0;
		String st1=JOptionPane.showInputDialog(null,"请输入长:","0");
		String st2=JOptionPane.showInputDialog(null,"请输入宽:","0");
		length=Double.parseDouble(st1);
		width=Double.parseDouble(st2);

		Rectangle re=new Rectangle(length,width);
		System.out.println("The circulme is: "+re.GetCirculme());
		System.out.println("The area is: "+re.GetArea());
		
		
		st1=Double.toString(re.GetCirculme());
		st2=Double.toString(re.GetArea());		
		JOptionPane.showMessageDialog(null,"The circulme is: "+st1);
		JOptionPane.showMessageDialog(null,"The area is: "+st2);*/
		
		double edge=0;
		String st=JOptionPane.showInputDialog(null,"请输入正方形边长:","0");
		edge=Double.parseDouble(st);
		Square square=new Square(edge);
		String st3=Double.toString(square.GetCirculme());
		String st4=Double.toString(square.GetArea());	
		JOptionPane.showMessageDialog(null,"The circulme is: "+st3);
		JOptionPane.showMessageDialog(null,"The area is: "+st4);
		
		
	}

}

public class Square extends Rectangle{
       double edge=0;
       public Square(){}
       public Square(double edge){
    	   super(edge,edge);
       }
}

⌨️ 快捷键说明

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