Commit 5a1f669c authored by Nurasyl's avatar Nurasyl

4 task

parent b9ec288c
const elevator = {
minFloor: 1,
maxFloor: 16,
currentFloor: 1,
toFloor: function(number) {
if(number > this.currentFloor) {
this.printFloor();
for(let i = this.currentFloor; i < number; i++) {
this.upOneFloor();
};
} else {
this.printFloor();
for(let i = this.currentFloor; i > number; i--) {
this.downOneFloor();
// const elevator = {
// minFloor: 1,
// maxFloor: 16,
// currentFloor: 1,
// toFloor: function(number) {
// if(number > this.currentFloor) {
// this.printFloor();
// for(let i = this.currentFloor; i < number; i++) {
// this.upOneFloor();
// };
// } else {
// this.printFloor();
// for(let i = this.currentFloor; i > number; i--) {
// this.downOneFloor();
// };
// };
// },
// printFloor: function() {
// console.log(`Этаж ${this.currentFloor}`);
// },
// upOneFloor : function() {
// if(this.currentFloor < this.maxFloor) {
// this.currentFloor++;
// this.printFloor();
// } else {
// console.log("Там самолеты.");
// }
// },
// downOneFloor: function() {
// if((this.currentFloor - 1) > this.minFloor) {
// this.currentFloor--;
// this.printFloor();
// } else {
// console.log("В аду нет лифтов");
// }
// }
// };
const initialList = ['John', 'Jack', 'Harry', 'Mario', 'Link', 'Zelda', 'Bowser'];
const Host = {
guestList: [],
setGuestList: function(arr) {
for(let i = 0; i < arr.length; i++) {
const randomNum = Math.round(Math.random() * 100);
if(randomNum < 20) {
console.log(`${arr[i]} не очень.`);
} else {
this.guestList.push(arr[i]);
};
};
},
printFloor: function() {
console.log(`Этаж ${this.currentFloor}`);
},
upOneFloor : function() {
if(this.currentFloor < this.maxFloor) {
this.currentFloor++;
this.printFloor();
} else {
console.log("Там самолеты.");
}
},
downOneFloor: function() {
if((this.currentFloor - 1) > this.minFloor) {
this.currentFloor--;
this.printFloor();
} else {
console.log("В аду нет лифтов");
}
}
};
\ No newline at end of file
};
Host.setGuestList(initialList);
console.log(Host.guestList);
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment