-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathelevator.py
More file actions
25 lines (25 loc) · 803 Bytes
/
elevator.py
File metadata and controls
25 lines (25 loc) · 803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
class Elevator:
def __init__(self, bottom, top, current):
"""Initializes the Elevator instance."""
self.bottom = bottom
self.top = top
self.current = current
pass
def up(self):
"""Makes the elevator go up one floor."""
if self.current < self.top:
self.current += 1
pass
def down(self):
"""Makes the elevator go down one floor."""
if self.current > self.bottom:
self.current -= 1
pass
def go_to(self, floor):
"""Makes the elevator go to the specific floor."""
self.current = floor
pass
def __str__(self):
"""Displays current floor when class printed"""
return "Current floor: {}".format(self.current)
elevator = Elevator(-1, 10, 0)