Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
61 changes: 51 additions & 10 deletions starter_code/elevator.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
6 changes: 6 additions & 0 deletions starter_code/index.js
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
const Elevator = require('./elevator.js');
const Person = require('./person.js');


const elevator = new Elevator;
elevator.start();
elevator.update();
11 changes: 11 additions & 0 deletions starter_code/package.json
Original file line number Diff line number Diff line change
@@ -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"
}
3 changes: 3 additions & 0 deletions starter_code/person.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
class Person {
constructor(name, originFloor, destinationFloor){
this.name = name;
this.originFloor = originFloor;
this.destinationFloor = destinationFloor;
}
}

Expand Down