Group 1 - ODD: Algorithms 2025
This project simulates an elevator system with features like floor requests, movement prioritization, and scenario handling (e.g., elevator failure). The system uses min-heap and max-heap data structures to manage pickup and dropoff requests efficiently. It also effectively uses queue for storing request, stack to keep track of recently visted floors, file handling to store the logs array for display of state.
- Set
CURRENT_FLOOR = 1. - Set
DIRECTION = IDLE. - Initialize:
- Min-Heap for dropoff requests.
- Max-Heap for pickup requests.
The system provides the following options:
- Request
- Move Elevator
- Display Elevator State
- Show Request Queue
- Scenarios (e.g., Elevator Failure)
- Log File
- Exit
- Prompt the user to input a floor number (1–9).
- Re-prompt if the input is non-integer or outside the valid range.
- Ask the user if the request is for pickup or dropoff.
- Use Max-Heap for pickup requests.
- Use Min-Heap for dropoff requests.
- Add the request to the appropriate priority queue.
- Move the elevator to the highest or lowest floor based on the current scenario.
- Prioritize dropoff requests over pickup requests.
- For example, if there is a pickup request on the 4th floor and a dropoff request on the 8th floor, the elevator will prioritize the dropoff first.
- Display the following information using an array of strings:
- Current Floor
- Direction (
IDLE,UP, orDOWN) - Next Stop
- Display all requests in the queue, sorted from largest to smallest.
- Use Min-Heap and Max-Heap to sort and prioritize floors.
- Elevator Failure:
- Trigger a boolean flag (
SYSTEM_FAILED = TRUE). - If the system is failed:
- Users cannot request the elevator.
- The system can be restarted by resetting the boolean flag (
SYSTEM_FAILED = FALSE).
- Trigger a boolean flag (
- Exit the scenarios menu to return to the main menu.
- Log all inputs and outputs to a file named
elevator.txt. - To reset the log, delete
elevator.txt.
- Exit the program.
- Handle non-integer inputs by prompting the user to enter a valid number (1–7).
- Ensure inputs do not exceed the valid range (1–7).
- Min-Heap: Used to prioritize dropoff requests (lowest floor first).
- Max-Heap: Used to prioritize pickup requests (highest floor first).
- A user requests a pickup on the 5th floor.
- Another user requests a dropoff on the 8th floor.
- The elevator prioritizes the dropoff request and moves to the 8th floor.
- After completing the dropoff, the elevator moves to the 5th floor for the pickup.
- All user inputs and system outputs are logged in
elevator.txt. - To reset the log, delete the file.
- Elevator Failure:
- When triggered, the system stops accepting requests.
- The system can be reset to resume normal operation.
- Exit the program.
- There is minimal usage of AI for practicing purposes. Understand that we are not perfect and we still need aid. Thank you.