diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/.DS_Store differ diff --git a/starter_code/elevator.js b/starter_code/elevator.js index 5339f35..55a36f0 100644 --- a/starter_code/elevator.js +++ b/starter_code/elevator.js @@ -2,18 +2,59 @@ class Elevator { constructor(){ this.floor = 0; this.MAXFLOOR = 10; + this.direction = ""; this.requests = []; + this.waitingList = []; + this.passengers = []; + this.timeoutId; } - start() { } - stop() { } - update() { } - _passengersEnter() { } - _passengersLeave() { } - floorUp() { } - floorDown() { } - call() { } - log() { } + start() { + this.timeoutId = setInterval( () => this.update, 1000); + } + stopE() { + clearInterval(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..96b4fa6 100644 --- a/starter_code/index.js +++ b/starter_code/index.js @@ -1 +1,7 @@ const Elevator = require('./elevator.js'); +const Person = require('./person.js'); + + +const elevator = new Elevator; +elevator.start(); +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; } }