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

Player

Provides all the logic to create instance of Player

Constructor Summary

Public Constructor
public

constructor(user: Object | *, options: Object)

Initializes a new instance of the Player class.

Member Summary

Public Members
public get
public set

isComputer(bool: Boolean): *

Method Summary

Public Methods
public

Returns string representation of Player instance

Public Constructors

public constructor(user: Object | *, options: Object) source

Initializes a new instance of the Player class.

Params:

NameTypeAttributeDescription
user Object | *

A user object.

options Object
  • optional
  • default: {}

Options.

Example:


Example 1

// Creating a new instance
var player1 = new Player({name: 'Player 1'});

Example 2

// You can pass any object that has defined toString() method:
var playerObj = {
  name: 'Ben',
  toString() { return this.name; }
};

var player2 = new Player(playerObj);

Public Members

public get isComputer: Boolean: * source

Return:

Boolean

Getter

public set isComputer(bool: Boolean): * source

Public Methods

public toString(): string source

Returns string representation of Player instance

Return:

string

String representation