This project is a simple console-based elevator simulation written in C++. It simulates a building with multiple elevators and floors, allowing users to call elevators and set floor destinations. The program uses console graphics for visualization.
Cpp_projects/ │ ├── msoftcon.h # Replacement for old "msoftcon.h", provides console functions ├── elev_app.h # Defines constants for number of floors and elevators ├── elev.h # Class declarations for Building and Elevator ├── elev.cpp # Class implementations for Building and Elevator └── elev_app.cpp # Main program entry point
-
msoftcon.h
Provides functions for console control: clear screen, set cursor position, colors, and simple wait. Replaces the old MS-DOSmsoftcon.h. -
elev_app.h
Defines global constants:NUM_FLOORS— number of floors in the building (20)NUM_CARS— number of elevators (4)
-
elev.h
Contains class declarations:class elevator— represents a single elevatorclass building— represents the building containing multiple elevators
Also defines thedirectionenum:UP,DN,STOP.
-
elev.cpp
Implements the behavior of elevators and building:- Elevator movement, loading/unloading timers
- Decision logic for elevator direction
- Display of elevator positions and floor requests
-
elev_app.cpp
Main program loop:- Initializes the building and elevators
- Handles ticks for elevators and user input for floor requests
- Multiple elevators (
NUM_CARS) moving independently in a building withNUM_FLOORSfloors - Console-based visualization of elevators and floor requests
- User input to call elevators and set floor destinations
- Simple load/unload simulation with timers
- Elevator decision-making logic (up/down/stop)
- Windows OS
- Visual Studio 2022 or MSVC Build Tools installed
- C++17 or later recommended
Open the Developer Command Prompt for VS 2022 and run:
cl elev_app.cpp elev.cpp /EHsc