C# Класс BattleshipUtility.Ship

Describes a ship
Наследование: ICloneable
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
Position Position

Открытые методы

Метод Описание
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

Описание методов

Adjacent() публичный Метод

Determines if a point is adjacent to a ship
public Adjacent ( Position p ) : bool
p Position position
Результат bool

Adjacent() публичный Метод

Returns true if a ship is adjacent to this ship
public Adjacent ( Ship ship ) : bool
ship Ship
Результат bool

AdjacentPositions() публичный Метод

List of positions adjacent to a ship
public AdjacentPositions ( int width, int height ) : IEnumerable
width int
height int
Результат IEnumerable

At() публичный Метод

Determines if a ship occupies a position
public At ( Position p ) : bool
p Position Position to check
Результат bool

AtOrAdjacent() публичный Метод

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
Результат bool

Clone() публичный Метод

public Clone ( ) : object
Результат object

Intersects() публичный Метод

Whether or not a ship intersects another ship
public Intersects ( Ship ship ) : bool
ship Ship
Результат bool

IntersectsOrAdjacent() публичный Метод

Whether or not a ship intersects or is next to another ship
public IntersectsOrAdjacent ( Ship ship ) : bool
ship Ship
Результат bool

Parse() публичный статический Метод

public static Parse ( string s ) : Ship
s string
Результат Ship

Place() публичный Метод

Randomly places a ship on a grid
public Place ( int width, int height ) : void
width int width of grid
height int height of grid
Результат void

ToString() публичный Метод

Describes a ship
public ToString ( ) : string
Результат string

Описание свойств

Position публичное свойство

Top-Left Position of the ship on the game board
public Position Position
Результат Position