KFury, I have replaced your human name with your Public Display Name for the purposes of naming this post. The point of HAVING a PDN is to shield your identity from your classmates and the wider world. We need to have a safe space for me to rudely (I mean mercilessly) (I mean candidly) critique your work without shaming you. Please change your Display Name.
—DSH
Instructions to an Elevator of a 5-floor hotel:
- Respond to any buttons Pressed on any floor
- When on that following floor open the doors for 15 seconds to wait for Passengers to enter
- If a Passenger interferes with the doors closing begin another 15-second timer before closing again
- If there are no presses on any of the corresponding buttons in the 15-second time frame close the doors and wait for a response from either the current or a different floor.
- If the Passenger presses one button Respond to the following floor
- If the Passenger presses two or more buttons on the 5th floor go to the nearest floor that was Pressed until each floor is visited
- If the passenger presses two or more buttons on the 4th floor go to the nearest floor UP first before proceeding to the floors that were selected DOWN.
- If the passenger presses two or more buttons on the 3rd floor go to the nearest floor UP first before proceeding to the floors that were selected DOWN.
- If the passenger presses two or more buttons on the second floor go to the nearest floor DOWN first before proceeding to the floors that were selected UP.
- If the Passenger presses two or more buttons on the 1st floor go to the nearest floor that was Pressed until each floor is visited
- If a Passenger presses a button on a floor en route to the floor Passengers already in the elevator selected, respond to the Passenger outside the elevator for pick up.
- If a Passenger presses a button on the 5th floor while there are Passengers already in the elevator below, respond to the selected floor to those in the elevator first before proceeding to the selected one above.
- If a Passenger presses a button on the 4th floor while there are Passengers already in the elevator on a floor BELOW, respond to the selected floor to those in the elevator first before proceeding to the selected one above.
- If a Passenger presses a button on the 4th floor while there are Passengers already in the elevator on the floor ABOVE, respond to the button on the 4th floor to pick the Passengers up.
- If a Passenger presses a button on the 3rd floor while there are Passengers already in the elevator on a floor BELOW, respond to the selected floor to those in the elevator first before proceeding to the selected one above.
- If a Passenger presses a button on the 3rd floor while there are Passengers already in the elevator on the floor ABOVE, respond to the button on the 3rd floor to pick the Passengers up.
- If a Passenger presses a button on the 2nd floor while there are Passengers already in the elevator on a floor BELOW, respond to the selected floor to those in the elevator first before proceeding to the selected one ABOVE.
- If a Passenger presses a button on the 2nd floor while there are Passengers already in the elevator on the floor ABOVE, respond to the button on the 2nd floor to pick the Passengers up.
- If a Passenger presses a button on the 1st floor while there are Passengers already in the elevator, respond to the selected floor to those in the elevator first before proceeding to the selected one BELOW.
- When all Responses are completed wait at the following floor that was requested by the Passenger.
You’re doing good work here, KFury. Want to do better? There are plenty of ways to improve.
I presume you mean the buttons OUTSIDE the elevator, which you might need to name for clarity. Call Buttons?
You use the term “following floor” often. What does it mean? “The next” floor? If so, what determines which floor is “next”? If the elevator is on the 3rd floor and buttons are pressed on the 4th and 2nd floors, is the 4th floor “next” because it’s closer? Or is the 2nd floor the “next” floor for an elevator that’s already headed “DOWN”?
15 seconds is an eternity on an elevator. Time it yourself the next time you’re on one.
What are “corresponding” buttons?
Again, what’s a “following floor”?
What one “passenger” presses two or more buttons? That can’t be what you mean.
Here you begin to show that you understand the prioritizing of actions “in the current direction.”
In NO WAY should you have to write instructions for EVERY SITUATION on EVERY FLOOR, KFury. Find a way to write General Rules that handle all situations.
The elevator NEVER NEEDS TO BE TOLD TO WAIT. If it has no instructions to respond to, it will do nothing. It’s not “waiting,” but it will look like waiting.
Is that helpful?