Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- export class BoardItem {
- _name;
- _status;
- _MAX_NAME_LENGTH = 20;
- _MIN_NAME_LENGTH = 6;
- constructor (name) {
- this._name = name;
- }
- /**
- * Sets the name of the note.
- * @param {string} value - The name to set.
- * @throws {Error} If the name is invalid or out of length bounds.
- */
- get name() {
- return this._name;
- }
- set name(value) {
- if(typeof value !== 'string') {
- throw new Error('Name cannot be diffrent from string!');
- }
- if(!value) {
- throw new Error('Name cannot be null, undefined or empty string!');
- }
- if (value.length < BoardItem._MIN_NAME_LENGTH || value.length > BoardItem._MAX_NAME_LENGTH) {
- throw new Error(`Length should be between ${BoardItem._MIN_NAME_LENGTH} and ${BoardItem._MAX_NAME_LENGTH}.`);
- }
- this._name = value;
- }
- get status() {
- return this._status;
- }
- reset() {
- this._status = 'new';
- }
- advance() {
- this._status = 'one step ahead';
- }
- complete() {
- this._status = 'finished';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment