Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // by SoftUni course JS Advanced
- // lesson Objects and Composition
- // assembly line task
- function createAssemblyLine() {
- return {
- hasClima: (car) => {
- car.temp = 21;
- car.tempSettings = 21;
- car.adjustTemp = () => {
- if (car.temp < car.tempSettings) car.temp++;
- else if (car.temp > car.tempSettings) car.temp--;
- };
- },
- hasAudio: (car) => {
- car.currentTrack = {
- name: null,
- artist: null,
- };
- car.nowPlaying = () => {
- if (car.currentTrack !== null) {
- console.log(
- `Now playing '${car.currentTrack.name}' by ${car.currentTrack.artist}`
- );
- }
- };
- },
- hasParktronic: (car) => {
- car.checkDistance = (n) => {
- if (n < 0.1) {
- console.log("Beep! Beep! Beep");
- } else if (n < 0.25) {
- console.log("Beep! Beep");
- } else if (n < 0.5) {
- console.log("Beep!");
- } else {
- console.log("");
- }
- };
- },
- };
- }
- const assemblyLine = createAssemblyLine();
- const myCar = {
- make: "Toyota",
- model: "Avensis",
- };
Advertisement