From 0162c3558b5b737cfbd4f6c9ce663ff9d44278fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pere=20Amor=C3=B3s?= Date: Tue, 30 Jan 2018 00:22:53 +0100 Subject: [PATCH 1/2] not finished --- .DS_Store | Bin 0 -> 6148 bytes starter_code/elevator.js | 60 +++++++++++++++++++++++++++++++------- starter_code/index.js | 5 ++++ starter_code/package.json | 11 +++++++ starter_code/person.js | 3 ++ 5 files changed, 69 insertions(+), 10 deletions(-) create mode 100644 .DS_Store create mode 100644 starter_code/package.json diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0 this.update, 1000); + } + stopE() { + clearTimeout(this.timeoutId); + } + update() { + this.log(); + } + _passengersEnter(person) { + //check if waitingList > 0 + + this.passengers.push(person.name); + //delete the passenger from the waitingList + + //add the destination floor of the passenger to the elvator requests + + //show a message --> Julia has enter the elevator + } + _passengersLeave() { + //check if passengers collection. destinationFloor === currentFloor + + //delete that person from the passengers array + + //show a message --> Julia has left the elevator + + } + floorUp() { + if(this.floor < 10 && this.floor >= 0){ + this.floor++; + console.log(this.floor); + } + } + floorDown() { + if(this.floor <= 10 && this.floor > 0){ + this.floor--; + } + } + call(person) { + this.requests.push(person); + this.waitingList.push(person.name); + this.requests.push(person.originFloor); + } + log() { + console.log(`Direction: ${this.direction} | Floor ${this.floor}`); + } } -module.exports = Elevator; +module.exports = Elevator; \ No newline at end of file diff --git a/starter_code/index.js b/starter_code/index.js index 5e480eb..5e507ed 100644 --- a/starter_code/index.js +++ b/starter_code/index.js @@ -1 +1,6 @@ const Elevator = require('./elevator.js'); +const Person = require('./person.js'); + + +const elevator = new Elevator; +elevator.update(); \ No newline at end of file diff --git a/starter_code/package.json b/starter_code/package.json new file mode 100644 index 0000000..3d6d922 --- /dev/null +++ b/starter_code/package.json @@ -0,0 +1,11 @@ +{ + "name": "starter_code", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "author": "", + "license": "ISC" +} diff --git a/starter_code/person.js b/starter_code/person.js index fddcc22..a58e4b0 100644 --- a/starter_code/person.js +++ b/starter_code/person.js @@ -1,5 +1,8 @@ class Person { constructor(name, originFloor, destinationFloor){ + this.name = name; + this.originFloor = originFloor; + this.destinationFloor = destinationFloor; } } From 1d34195d8274c78fb16f1ec4717336653e3778b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pere=20Amor=C3=B3s?= Date: Tue, 30 Jan 2018 08:54:23 +0100 Subject: [PATCH 2/2] till iteration 4 more less --- starter_code/elevator.js | 3 ++- starter_code/index.js | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/starter_code/elevator.js b/starter_code/elevator.js index 5c435b9..55a36f0 100644 --- a/starter_code/elevator.js +++ b/starter_code/elevator.js @@ -6,13 +6,14 @@ class Elevator { this.requests = []; this.waitingList = []; this.passengers = []; + this.timeoutId; } start() { this.timeoutId = setInterval( () => this.update, 1000); } stopE() { - clearTimeout(this.timeoutId); + clearInterval(this.timeoutId); } update() { this.log(); diff --git a/starter_code/index.js b/starter_code/index.js index 5e507ed..96b4fa6 100644 --- a/starter_code/index.js +++ b/starter_code/index.js @@ -3,4 +3,5 @@ const Person = require('./person.js'); const elevator = new Elevator; +elevator.start(); elevator.update(); \ No newline at end of file