mihalkoff

Assembly line

Jan 23rd, 2022 (edited)
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. function createAssemblyLine() {
  2. let assembly = {
  3. hasClima(car) {
  4. car.temp = 21;
  5. car.tempSettings = 21;
  6. car.adjustTemp = () => {
  7. if(car.temp < car.tempSettings) {
  8. car.temp++;
  9. } else if(car.temp > car.tempSettings) {
  10. car.temp--;
  11. }
  12. };
  13. },
  14. hasAudio(car) {
  15. car.currentTrack = {
  16. name: null,
  17. artist: null
  18. };
  19. car.nowPlaying = () => {
  20. console.log(`Now playing '${car.currentTrack.name}' by ${car.currentTrack.artist}`);
  21. };
  22. },
  23. hasParktronic(car) {
  24. car.checkDistance = (distance) => {
  25. if(distance < 0.1) {
  26. console.log("Beep! Beep! Beep!");
  27. } else if(distance >= 0.1 && distance < 0.25) {
  28. console.log("Beep! Beep!");
  29. } else if(distance >= 0.25 && distance < 0.5) {
  30. console.log("Beep!");
  31. } else {
  32. console.log('');
  33. }
  34. };
  35. }
  36. }
  37.  
  38. return assembly;
  39. }
  40.  
  41. const assemblyLine = createAssemblyLine();
  42.  
  43. const myCar = {
  44. make: 'Toyota',
  45. model: 'Avensis'
  46. };
  47.  
  48. console.log(myCar);
Add Comment
Please, Sign In to add comment