Skip to content

This is a Java-based elevator simulator program that demonstrates the functionality of a single-threaded elevator system. The program is designed using core Java concepts, including object-oriented principles and the collection framework. The simulator allows users to call the elevator, board passengers, and move between floors.

swapniltake1/Elevator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Elevator (Task 1 - YHills Java Training)

Q. Design and code an Elevator. You can use any JDK, preferably JDK 8 and use collection framework, OOP principles to design a single thread elevator programme. This will test your knowledge of CORE Java. Remember to use all the standard and good programming habits while programming.

Flow Of Code

  1. The Elevator class maintains the current floor, direction of movement, a map of requested paths (people waiting on each floor and their destinations), and an array to track the floors the elevator will visit.

  2. The start() method repeatedly calls the processFloor() method until the elevator becomes idle.

  3. The processFloor() method unloads passengers, boards passengers, updates the current floor destinations, and calls moveElevator() to determine the next direction and move the elevator.

  4. The moveElevator() method determines the direction based on the current floor and updates the currentDirection variable accordingly.

  5. The elevator moves up or down based on the current direction and waits between each floor.

  6. The callElevator() method adds user requests to the requestedPathsMap.

  7. The main method creates an Elevator object, allows users to manually call the elevator, and starts the elevator.

Output Screenshot

image

About

This is a Java-based elevator simulator program that demonstrates the functionality of a single-threaded elevator system. The program is designed using core Java concepts, including object-oriented principles and the collection framework. The simulator allows users to call the elevator, board passengers, and move between floors.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages