Home Reference Source
import {Tile} from './js/tile.js'
public class | source

Tile

Direct Implemented:

A class for Tile, the element inside a board.

Constructor Summary

Public Constructor
public

Constructor creates a tile that stores whether the tile is a mine or not, the number of mines adjacent to it, and whether the tile has been flagged or not.

Member Summary

Public Members
public

Number of mines adjacent to the tile.

public

Flag status of the tile.

public

A mine or not a mine.

public

Revealed status of the tile.

Method Summary

Public Methods
public

flag()

Reverses the flag status of the tile.

public

Gets the number of mines adjacent to the tile.

public

Gets whether the tile has been flagged or not.

public

Gets whether the tile is a mine or not.

public

Gets whether the tile has been revealed or not.

public

reveal()

Reveals the tile, setting revealed to true.

public

Sets the number of mines adjacent to the tile.

public

Sets the tile's status to be a mine. POSTCONDITION: isMine is true.

Public Constructors

public constructor() source

Constructor creates a tile that stores whether the tile is a mine or not, the number of mines adjacent to it, and whether the tile has been flagged or not. POSTCONDITION: isMine, adjNum, flagged, and revealed, all now have set values.

Public Members

public adjNum: number source

Number of mines adjacent to the tile.

public flagged: boolean source

Flag status of the tile.

public isMine: boolean source

A mine or not a mine.

public revealed: boolean source

Revealed status of the tile.

Public Methods

public flag() source

Reverses the flag status of the tile. If it has been flagged, set to false. If it has not, set to true. POSTCONDTION: flagged is inverted

public getAdjacent(): number source

Gets the number of mines adjacent to the tile.

Return:

number

adjNum

public getFlagged(): boolean source

Gets whether the tile has been flagged or not.

Return:

boolean

flagged

public getMine(): boolean source

Gets whether the tile is a mine or not.

Return:

boolean

isMine

public getRevealed(): boolean source

Gets whether the tile has been revealed or not.

Return:

boolean

flagged

public reveal() source

Reveals the tile, setting revealed to true. POSTCONDTION: revealed is true.

public setAdjacent(adj: number) source

Sets the number of mines adjacent to the tile. POSTCONDITION: adjNum could be anywhere from 0 to 8

Params:

NameTypeAttributeDescription
adj number

Number of mine adjacent to this tile, retrieved from plantAdjNum()

public setMine() source

Sets the tile's status to be a mine. POSTCONDITION: isMine is true.