Class: Subamrines

Subamrines()

Class representing a collection of submarine instances. Manages multiple submarine models and allows switching between them. Extends EventEmitter to handle events related to submarine switching.

Constructor

new Subamrines()

Initializes an instance of the Submarines class.
Source:

Methods

getCurrentSubmarine() → {Submarine}

Retrieves the currently active submarine instance.
Source:
Returns:
- The current submarine instance.
Type
Submarine

getSubmarine(type) → {Submarine}

Retrieves a submarine instance based on the specified type.
Parameters:
Name Type Description
type SubmarineType The type of submarine to retrieve.
Source:
Returns:
- The submarine instance corresponding to the type.
Type
Submarine

initItems()

Initializes the collection of submarine instances with predefined submarines (Ohio and Typhoon). Private method called during class instantiation.
Source:

initOhio() → {Submarine}

Initializes an Ohio class submarine instance with predefined constants and state.
Source:
Returns:
- The initialized Ohio submarine instance.
Type
Submarine

initTyphoon() → {Submarine}

Initializes a Typhoon class submarine instance with predefined constants and state.
Source:
Returns:
- The initialized Typhoon submarine instance.
Type
Submarine

switchSubmarine(submarine)

Switches the active submarine to the one specified. Emits a 'SwitchSubmarine' event upon switching.
Parameters:
Name Type Description
submarine SubmarineType | string The type or name of the submarine to switch to.
Source: