C# Class HelloWorld.Coordinate

Show file Open project: Ivony/HelloWorld

Public Methods

Method Description
Create ( int x, int y ) : Coordinate

创建一个坐标对象

Distance ( Coordinate coordinate ) : int

计算与另一个坐标的距离

Equals ( object obj ) : bool
GetCoordinate ( Direction direction ) : Coordinate
GetHashCode ( ) : int
NearlyCoordinates ( int distance = 1 ) : Coordinate[]

获取临近的坐标

Parse ( string expression ) : Coordinate

从字符串中解析出坐标信息

RandomCoordinate ( int x, int y ) : Coordinate

取一个不超出指定范围的随机坐标

ToString ( ) : string

将坐标转换为字符串形式

TryCreate ( int x, int y, Coordinate &coordinate ) : bool

尝试创建坐标对象

operator ( ) : Coordinate

计算两个坐标相加后的结果

operator ( ) : bool

Private Methods

Method Description
Coordinate ( ) : System
GetAdjacents ( int distance ) : HashSet

Method Details

Create() public static method

创建一个坐标对象
public static Create ( int x, int y ) : Coordinate
x int
y int
return Coordinate

Distance() public method

计算与另一个坐标的距离
public Distance ( Coordinate coordinate ) : int
coordinate Coordinate 要计算距离的坐标
return int

Equals() public method

public Equals ( object obj ) : bool
obj object
return bool

GetCoordinate() public method

public GetCoordinate ( Direction direction ) : Coordinate
direction Direction
return Coordinate

GetHashCode() public method

public GetHashCode ( ) : int
return int

NearlyCoordinates() public method

获取临近的坐标
public NearlyCoordinates ( int distance = 1 ) : Coordinate[]
distance int 距离
return Coordinate[]

Parse() public static method

从字符串中解析出坐标信息
public static Parse ( string expression ) : Coordinate
expression string 包含坐标信息的字符串
return Coordinate

RandomCoordinate() public static method

取一个不超出指定范围的随机坐标
public static RandomCoordinate ( int x, int y ) : Coordinate
x int x取值范围
y int y取值范围
return Coordinate

ToString() public method

将坐标转换为字符串形式
public ToString ( ) : string
return string

TryCreate() public static method

尝试创建坐标对象
public static TryCreate ( int x, int y, Coordinate &coordinate ) : bool
x int
y int
coordinate Coordinate
return bool

operator() public static method

计算两个坐标相加后的结果
public static operator ( ) : Coordinate
return Coordinate

operator() public static method

public static operator ( ) : bool
return bool