Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
W
webinar_12_AJS-13
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
Nikolay Tarassenko
webinar_12_AJS-13
Commits
803816ea
Commit
803816ea
authored
Feb 08, 2023
by
Nikolay Tarassenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Добавил объект Elevator c методами
parent
d0ed4ccc
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
0 deletions
+53
-0
index.js
js/index.js
+53
-0
No files found.
js/index.js
View file @
803816ea
const
Elevator
=
{
currentFloor
:
1
,
maxFloor
:
16
,
minFloor
:
1
,
printFloor
()
{
console
.
log
(
`Elevator is on the floor
${
this
.
currentFloor
}
`
);
},
upOneFloor
()
{
if
(
this
.
currentFloor
<
this
.
maxFloor
)
this
.
currentFloor
++
;
},
downOneFloor
()
{
if
(
this
.
currentFloor
>
this
.
minFloor
)
this
.
currentFloor
--
;
},
toFloor
(
floor
)
{
this
.
printFloor
();
if
(
floor
<
this
.
minFloor
||
floor
>
this
.
maxFloor
)
{
console
.
log
(
'Invalid floor'
);
return
;
}
while
(
this
.
currentFloor
<
floor
)
{
this
.
upOneFloor
();
this
.
printFloor
();
}
if
(
this
.
currentFloor
>
floor
)
{
for
(
let
i
=
this
.
currentFloor
;
i
>
floor
;
i
--
)
{
this
.
downOneFloor
();
this
.
printFloor
();
}
}
},
};
// Elevator.printFloor();
// Elevator.upOneFloor();
// Elevator.downOneFloor();
// Elevator.downOneFloor();
// Elevator.downOneFloor();
// Elevator.downOneFloor();
// Elevator.downOneFloor();
// Elevator.printFloor();
Elevator
.
toFloor
(
16
);
Elevator
.
toFloor
(
17
);
Elevator
.
upOneFloor
();
Elevator
.
printFloor
();
// 1,2,3,4,5,6,7,8,9,10
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