Advertisement
simeonshopov

Assembly Line

May 24th, 2021
639
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  *
  3.  * @returns {Object}
  4.  */
  5. function createAssemblyLine() {
  6.   let decorators = {};
  7.  
  8.   /**
  9.    *
  10.    * @param {Object} obj
  11.    */
  12.   decorators.hasClima = function(obj) {
  13.     obj.temp = 21;
  14.     obj.tempSettings = 21;
  15.     obj.adjustTemp = function() {(obj.temp < obj.tempSettings) ? obj.temp += 1 : (obj.temp > obj.tempSettings)? obj.temp -= 1 : obj.temp}
  16.   };
  17.  
  18.   /**
  19.    *
  20.    * @param {Object} obj
  21.    */
  22.   decorators.hasAudio = function(obj) {
  23.     obj.currentTrack = null;
  24.     obj.nowPlaying = function() { if (obj.currentTrack !== null) console.log(`Now playing ${obj.currentTrack.name} by ${obj.currentTrack.artist}`); }
  25.   };
  26.  
  27.   /**
  28.    *
  29.    * @param {Object} obj
  30.    */
  31.   decorators.hasParktronic = function(obj) {
  32.     obj.checkDistance = function(distance) {
  33.       if (distance < 0.1) {
  34.         console.log('Beep! Beep! Beep!');
  35.       } else if (0.1 <= distance && distance < 0.25) {
  36.         console.log('Beep! Beep!');
  37.       } else if (0.25 <= distance && distance < 0.5) {
  38.         console.log('Beep!');
  39.       } else {console.log('');}
  40.     };
  41.   };
  42.  
  43.   return decorators;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement