Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
C
classwork_23
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Нұрасыл Қайратұлы
classwork_23
Commits
5a1f669c
Commit
5a1f669c
authored
Dec 12, 2023
by
Nurasyl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
4 task
parent
b9ec288c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
61 additions
and
38 deletions
+61
-38
index.js
JS/index.js
+61
-38
No files found.
JS/index.js
View file @
5a1f669c
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment