C# Class BattleshipUtility.Ship

Describes a ship
Inheritance: ICloneable
Afficher le fichier Open project: solium/hacklympics Class Usage Examples

Méthodes publiques

Свойство Type Description
Position Position

Méthodes publiques

Méthode 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 méthode

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

Adjacent() public méthode

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

AdjacentPositions() public méthode

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

At() public méthode

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

AtOrAdjacent() public méthode

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
Résultat bool

Clone() public méthode

public Clone ( ) : object
Résultat object

Intersects() public méthode

Whether or not a ship intersects another ship
public Intersects ( Ship ship ) : bool
ship Ship
Résultat bool

IntersectsOrAdjacent() public méthode

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

Parse() public static méthode

public static Parse ( string s ) : Ship
s string
Résultat Ship

Place() public méthode

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

ToString() public méthode

Describes a ship
public ToString ( ) : string
Résultat string

Property Details

Position public_oe property

Top-Left Position of the ship on the game board
public Position Position
Résultat Position