Advertisement
Guest User

Untitled

a guest
Apr 7th, 2020
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.13 KB | None | 0 0
  1. # Code cell 17
  2. class Elevator:
  3.  
  4.     def __init__(self, floor_numbers, floor_types):
  5.         self._floor_numbers = floor_numbers
  6.         self._floor_types = floor_types
  7.         self._number_to_type_dict = dict(zip(floor_numbers, floor_types))
  8.         self._type_to_number_dict = dict(zip(floor_types, floor_numbers))
  9.  
  10.     def ask_which_floor(self, floor_type):
  11.         if floor_type in self._floor_types:
  12.             print('The {} floor is the number: {}.'.format(floor_type, self._type_to_number_dict[floor_type]))
  13.         else:
  14.             print('There is no {} floor in this building.'.format(floor_type))
  15.  
  16.     def go_to_floor(self, floor_number):
  17.         if floor_number in self._floor_numbers:
  18.             print('Going to {} floor .'.format(self._number_to_type_dict[floor_number]))
  19.         else:
  20.             print('There is floor number {} in this building.'.format(floor_number))
  21.  
  22. floor_types = ['Parking', 'Shops', 'Food Court', 'Offices']
  23. floor_numbers = range(-1, 4)
  24.  
  25. el = Elevator(floor_numbers, floor_types)
  26.  
  27. el.go_to_floor(1)
  28.  
  29. el.go_to_floor(-2)
  30.  
  31. el.ask_which_floor('Offices')
  32.  
  33. el.ask_which_floor('Swimming Pool')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement