C#程序设计(5-2)

来源:百度知道 编辑:UC知道 时间:2024/05/15 03:17:02
编写一个对正方形提供绘制和操作的代码。在该代码中,正方形类的字段有正方形的边长和窗口上正方形开始的位置;正方形类的方法有绘制正方形和返回正方形边长、开始位置、周长、面积。

using System;
using System.Collections.Generic;
using System.Text;
using System.Drawing;
using System.Drawing.Drawing2D;

namespace SquareTest
{
public class Square
{
public Square()
{
}
private double borderSize;
private Point location;
/// <summary>
/// 正方形开始位置
/// </summary>
public Point Location
{
get { return location; }
set { location = value; }
}
/// <summary>
/// 边长
/// </summary>
public double BorderSize
{
get { return borderSize; }
set { borderSize = value; }
}
/// <summary>
/// 获得正方形的周长
/// </summary>
/// <returns></returns>