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

📄 矩形.txt

📁 c语言多个实用小程序,会有帮助的~ 自己瞎编的
💻 TXT
字号:
using System;
class Rectangle
{
	private float length=1.0f;
	private float width=1.0f;

	public float SetLength(float length)
	{
		this.length=length;
		if((length<0.0f)||(length>2.0f))
		{
			Console.WriteLine ("长的取值范围应在1.0-2.0之内,请重新设值。");
			return 0.0f;
		}
		return width;
	}
	public float SetWidth(float width)
	{
        this.width=width;
		if((width<0.0f)||(width>2.0f))
		{
			Console.WriteLine ("宽的取值范围应在1.0-2.0之内,请重新设值。");	
			return 0.0f;
		}
		return width;
	}
	public float GetLength(float length)
	{
		return length;
	}
	public float GetWidth(float width)
	{
		return width;  
	}
	public float perimeter()
	{
		return length*2+width*2;
	}
	public float area()
	{
	   return length*width;
	}

}
class Rectangle_Test
{
	public static void Main()
	{
		Rectangle r1=new Rectangle ();
		r1.SetLength (1.8f);
		r1.SetWidth (1.2f);
	    Console.WriteLine (r1.perimeter ());
		Console.WriteLine (r1.area ());

	}

}

⌨️ 快捷键说明

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