ALSAVOV

assembly line

Aug 3rd, 2025 (edited)
124
0
Never
6
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // by SoftUni course JS Advanced
  2. // lesson Objects and Composition
  3. // assembly line task
  4.  
  5. function createAssemblyLine() {
  6.     return {
  7.         hasClima: (car) => {
  8.             car.temp = 21;
  9.             car.tempSettings = 21;
  10.             car.adjustTemp = () => {
  11.                 if (car.temp < car.tempSettings) car.temp++;
  12.                 else if (car.temp > car.tempSettings) car.temp--;
  13.             };
  14.         },
  15.  
  16.         hasAudio: (car) => {
  17.             car.currentTrack = {
  18.                 name: null,
  19.                 artist: null,
  20.             };
  21.             car.nowPlaying = () => {
  22.                 if (car.currentTrack !== null) {
  23.                     console.log(
  24.                         `Now playing '${car.currentTrack.name}' by ${car.currentTrack.artist}`
  25.                     );
  26.                 }
  27.             };
  28.         },
  29.  
  30.         hasParktronic: (car) => {
  31.             car.checkDistance = (n) => {
  32.                 if (n < 0.1) {
  33.                     console.log("Beep! Beep! Beep");
  34.                 } else if (n < 0.25) {
  35.                     console.log("Beep! Beep");
  36.                 } else if (n < 0.5) {
  37.                     console.log("Beep!");
  38.                 } else {
  39.                     console.log("");
  40.                 }
  41.             };
  42.         },
  43.     };
  44. }
  45.  
  46. const assemblyLine = createAssemblyLine();
  47.  
  48. const myCar = {
  49.     make: "Toyota",
  50.     model: "Avensis",
  51. };
Advertisement
Comments
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
  • User was banned
Add Comment
Please, Sign In to add comment