UNPKG

game-battleship

Version:
96 lines (69 loc) 2.39 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JSDoc: Source: ship.js</title> <script src="scripts/prettify/prettify.js"> </script> <script src="scripts/prettify/lang-css.js"> </script> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css"> <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css"> </head> <body> <div id="main"> <h1 class="page-title">Source: ship.js</h1> <section> <article> <pre class="prettyprint source linenums"><code>/** * This entity is representing the ship * * @class Ship * @constructor * @param {string} type - This defines the type of the ship "P" &amp; "Q" * @param {Array} dimension - Represnts the dimension of the ship * @param {Array} coordinates - Represnts the coordinates of the ship */ class Ship { constructor({type, dimension, coordinates}) { this.type_ = type; if (this.type_ === "P") { this.hitCount_ = 1; } else if (this.type_ === "Q") { this.hitCount_ = 2; } this.dimension = dimension; this.coordinates = coordinates; } /** * Function to check if the ship is destroyed * @returns {Boolean} returns true if ship is destroyed else false */ isDestroyed() { return !this.hitCount_; } /** * Function to bombard the ship * @returns {null} returns nothing */ bombard() { this.hitCount_--; } } module.exports = Ship; </code></pre> </article> </section> </div> <nav> <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Area.html">Area</a></li><li><a href="Player.html">Player</a></li><li><a href="Ship.html">Ship</a></li></ul><h3>Global</h3><ul><li><a href="global.html#battle">battle</a></li><li><a href="global.html#fileReader">fileReader</a></li><li><a href="global.html#parseCoordinates">parseCoordinates</a></li><li><a href="global.html#validateArgs">validateArgs</a></li></ul> </nav> <br class="clear"> <footer> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Tue Feb 19 2019 14:14:50 GMT+0530 (India Standard Time) </footer> <script> prettyPrint(); </script> <script src="scripts/linenumber.js"> </script> </body> </html>