From ea9984cfff206014ae4eb248644833505b618b0a Mon Sep 17 00:00:00 2001 From: Enrique Garcia Date: Tue, 13 Feb 2018 09:10:34 -0600 Subject: [PATCH] half way done --- starter_code/elevator.js | 37 ++++++++++++++++++++++++++++++------- starter_code/index.js | 8 ++++++++ starter_code/person.js | 1 + 3 files changed, 39 insertions(+), 7 deletions(-) diff --git a/starter_code/elevator.js b/starter_code/elevator.js index 5339f35..ef91ce3 100644 --- a/starter_code/elevator.js +++ b/starter_code/elevator.js @@ -3,17 +3,40 @@ class Elevator { this.floor = 0; this.MAXFLOOR = 10; this.requests = []; + this.direction = "up"; + + } + + start() { + this.interval = setInterval( () => this.update,1000); } - start() { } - stop() { } - update() { } + stop(){ + clearInterval(this.interval); + } + update() { + this.log() + } _passengersEnter() { } _passengersLeave() { } - floorUp() { } - floorDown() { } - call() { } - log() { } + floorUp() { + if(this.floor<10){ + this.floor ++ + } + } + floorDown() { + if( this.floor > 0){ + this.floor -- + } + + } + call(person) { + this.requests.push(person); + console.log(this.requests.length); + } + log() { + console.log(`Direction:${this.direction} Floor: ${this.floor}` ) + } } module.exports = Elevator; diff --git a/starter_code/index.js b/starter_code/index.js index 5e480eb..7a5909d 100644 --- a/starter_code/index.js +++ b/starter_code/index.js @@ -1 +1,9 @@ const Elevator = require('./elevator.js'); +const Person = require(`./person.js`); + + +let myElevator = new Elevator(); +myElevator.start(); +myElevator.update(); +myElevator.floorUp(); +myElevator.update(); diff --git a/starter_code/person.js b/starter_code/person.js index fddcc22..b6a9446 100644 --- a/starter_code/person.js +++ b/starter_code/person.js @@ -1,5 +1,6 @@ class Person { constructor(name, originFloor, destinationFloor){ + } }