C# Class BattleshipUtility.Ship

Describes a ship
Inheritance: ICloneable
显示文件 Open project: solium/hacklympics Class Usage Examples

Public Properties

Property Type Description
Position Position

Public Methods

Method Description
Adjacent ( Position p ) : bool

Determines if a point is adjacent to a ship

Adjacent ( Ship ship ) : bool

Returns true if a ship is adjacent to this ship

AdjacentPositions ( int width, int height ) : IEnumerable

List of positions adjacent to a ship

At ( Position p ) : bool

Determines if a ship occupies a position

AtOrAdjacent ( Position p ) : bool

Creates a 1-space border around a ship and checks if a position is within this border

Clone ( ) : object
Intersects ( Ship ship ) : bool

Whether or not a ship intersects another ship

IntersectsOrAdjacent ( Ship ship ) : bool

Whether or not a ship intersects or is next to another ship

Parse ( string s ) : Ship
Place ( int width, int height ) : void

Randomly places a ship on a grid

ToString ( ) : string

Describes a ship

Method Details

Adjacent() public method

Determines if a point is adjacent to a ship
public Adjacent ( Position p ) : bool
p Position position
return bool

Adjacent() public method

Returns true if a ship is adjacent to this ship
public Adjacent ( Ship ship ) : bool
ship Ship
return bool

AdjacentPositions() public method

List of positions adjacent to a ship
public AdjacentPositions ( int width, int height ) : IEnumerable
width int
height int
return IEnumerable

At() public method

Determines if a ship occupies a position
public At ( Position p ) : bool
p Position Position to check
return bool

AtOrAdjacent() public method

Creates a 1-space border around a ship and checks if a position is within this border
public AtOrAdjacent ( Position p ) : bool
p Position Position to check
return bool

Clone() public method

public Clone ( ) : object
return object

Intersects() public method

Whether or not a ship intersects another ship
public Intersects ( Ship ship ) : bool
ship Ship
return bool

IntersectsOrAdjacent() public method

Whether or not a ship intersects or is next to another ship
public IntersectsOrAdjacent ( Ship ship ) : bool
ship Ship
return bool

Parse() public static method

public static Parse ( string s ) : Ship
s string
return Ship

Place() public method

Randomly places a ship on a grid
public Place ( int width, int height ) : void
width int width of grid
height int height of grid
return void

ToString() public method

Describes a ship
public ToString ( ) : string
return string

Property Details

Position public_oe property

Top-Left Position of the ship on the game board
public Position Position
return Position