Home Reference Source Repository
import Throw from 'darts-scorer-core/src/throw.js'
public class | source

Throw

Class representing a single Throw

Static Method Summary

Static Public Methods
public static

create(num: number, multiplier: number): Throw

Factory function.

public static

Factory function.

Constructor Summary

Public Constructor
public

constructor(num: number, multiplier: number)

Initializes a new instance of the Throw class.

Member Summary

Public Members
public get
public get
public get
public get
public set

multiplier(multiplier: Number): *

Sets multiplier.

public get

Returns one of the followings: 'S' (single) or 'D' (double) or 'T' (triple)

public get
public set

number(num: Number): *

Sets number.

Method Summary

Public Methods
public

Static Public Methods

public static create(num: number, multiplier: number): Throw source

Factory function.

Params:

NameTypeAttributeDescription
num number

Number between 0 and 20 plus 25 (bull)

multiplier number
  • optional
  • default: 1

Multiplier is between 1 and 3 for all of the numbers but 25 (which has only x2 multiplier).

Return:

Throw

Instance of the Throw class.

public static fromString(str: string): Throw source

Factory function.

Params:

NameTypeAttributeDescription
str string

String representing the throw

Return:

Throw

Instance of the Throw class.

Example:

let throwInstance1 = Throw.fromString('T20'); // triple 20
let throwInstance2 = Throw.fromString('S15'); // single 15
let throwInstance3 = Throw.fromString('DB'); // double Bull

Public Constructors

public constructor(num: number, multiplier: number) source

Initializes a new instance of the Throw class.

Params:

NameTypeAttributeDescription
num number

Number between 0 and 20 plus 25 (bull)

multiplier number
  • optional
  • default: 1

Multiplier is between 1 and 3 for all of the numbers but 25 (which has only x2 multiplier).

Public Members

public get isDouble: boolean: * source

Return:

boolean

Helper getter.

public get isSingle: boolean: * source

Return:

boolean

Helper getter.

public get isTriple: boolean: * source

Return:

boolean

Helper getter.

public get multiplier: Number: * source

Return:

Number

Getter multiplier.

public set multiplier(multiplier: Number): * source

Sets multiplier.

public get multiplierAsString: number: * source

Returns one of the followings: 'S' (single) or 'D' (double) or 'T' (triple)

Return:

number

String representing multiplier

Example:

let throwInstance = new Throw(10, 2);
throwInstance.multiplierAsString //=> 'D'

public get number: Number: * source

Return:

Number

Getter number.

public set number(num: Number): * source

Sets number.

Public Methods

public toString(): string source

Return:

string

String representation of the Throw instance.