Skip to content

GuseinovRusik/elev

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Elevator Simulation in C++

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.


Project Structure

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

File Descriptions

  • msoftcon.h
    Provides functions for console control: clear screen, set cursor position, colors, and simple wait. Replaces the old MS-DOS msoftcon.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 elevator
    • class building — represents the building containing multiple elevators
      Also defines the direction enum: 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

Features

  • Multiple elevators (NUM_CARS) moving independently in a building with NUM_FLOORS floors
  • 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)

Requirements

  • Windows OS
  • Visual Studio 2022 or MSVC Build Tools installed
  • C++17 or later recommended

Compilation

Open the Developer Command Prompt for VS 2022 and run:

cl elev_app.cpp elev.cpp /EHsc

About

logic for elevator in cpp

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors