point2.cs
来自「this is a good book for the visual c#」· CS 代码 · 共 71 行
CS
71 行
// Fig. 10.5: Point2.cs
// Point2 inherits from abstract class Shape and represents
// an x-y coordinate pair.
using System;
namespace AbstractShapes
{
// Point2 inherits from abstract class Shape
public class Point2 : Shape
{
private int x, y; // Point2 coordinates
// default constructor
public Point2()
{
// implicit call to Object constructor occurs here
}
// constructor
public Point2( int xValue, int yValue )
{
X = xValue;
Y = yValue;
}
// propertyX
public int X
{
get
{
return x;
}
set
{
x = value; // no validation needed
}
}
// property Y
public int Y
{
get
{
return y;
}
set
{
y = value; // no validation needed
}
}
// return string representation of Point2 object
public override string ToString()
{
return "[" + X + ", " + Y + "]";
}
// implement abstract property Name of class Shape
public override string Name
{
get
{
return "Point2";
}
}
} // end class Point2
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?