{"id":22704991,"url":"https://github.com/benji377/tug-introductiontoc-02","last_synced_at":"2025-03-29T20:23:11.323Z","repository":{"id":264506769,"uuid":"745856419","full_name":"Benji377/TUG-IntroductionToC-02","owner":"Benji377","description":"Elevator Simulator in C | Lecture exercise","archived":false,"fork":false,"pushed_at":"2024-01-20T11:01:55.000Z","size":1814,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-25T18:12:35.254Z","etag":null,"topics":["c","simulation"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Benji377.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-20T11:01:16.000Z","updated_at":"2024-04-10T12:50:19.000Z","dependencies_parsed_at":"2024-11-24T23:45:29.757Z","dependency_job_id":null,"html_url":"https://github.com/Benji377/TUG-IntroductionToC-02","commit_stats":null,"previous_names":["benji377/tug-introductiontoc-02"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Benji377%2FTUG-IntroductionToC-02","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Benji377%2FTUG-IntroductionToC-02/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Benji377%2FTUG-IntroductionToC-02/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Benji377%2FTUG-IntroductionToC-02/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Benji377","download_url":"https://codeload.github.com/Benji377/TUG-IntroductionToC-02/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246238722,"owners_count":20745586,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["c","simulation"],"created_at":"2024-12-10T09:08:38.657Z","updated_at":"2025-03-29T20:23:11.307Z","avatar_url":"https://github.com/Benji377.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Assignment 2 - Elevator Simulation Program\n\n## Introduction\nIn Assignment 2 (A2) of the ESP practicals (KU), you will implement a program that simulates elevators in a hotel. Please make sure that you follow the assignment description strictly. Even slight differences can cause testcases to fail.\n\nThis document describes the structure of the assignment and the expected functionality of the program.\n\n### Learning Goals\nArrays, Strings, Pointers, Memory Management/Heap\n\n### Specifications\n\nSome general specifications must be followed for every assignment in this course. A list of these specifications can be found here:\n[Assessment of Assignments - Deductions](https://www.notion.so/coding-tugraz/Assessment-of-Assignments-How-do-you-get-your-points-d7cca6cc89a344e38ad74dd3ccb73cb3?pvs=4#e3203e50b1fc4ba787bdbf5fb46262ae). Please follow these specifications to avoid point deductions. As memory management is a central learning goal of this assignment, pay close attention to this section within the specifications.\n\nAdditionally, the following specifications must be followed for this assignment (A2) as well:\n* **Attention:** The `\u003cstring.h\u003e` library must **not** be used within this assignment! If `\u003cstring.h\u003e` is used, this will result in a **deduction of up to -25 %**.\n* **Attention:** `malloc()` (or `calloc()`) and `free()` must be used. ***All*** integer arrays whose size depends on entered values (e.g., number of floors and elevators, elevator capacity, people per floor) must be stored on the heap. If these arrays are not stored on the heap, this will result in a deduction of **up to -25 %**. For simplicity, you can use an array on the stack (e.g., ```char buffer[100];```) for string inputs (e.g., hotel name, storing yes/no, etc.). \n\n### Grading\nAssignment 2 is worth **24 points**.\n\nInformation on how your assignment submission will be assessed can be found here: [Assessment of Assignments](https://www.notion.so/coding-tugraz/Assessment-of-Assignments-How-do-you-get-your-points-d7cca6cc89a344e38ad74dd3ccb73cb3).\nPlease read this carefully, as it also contains guidelines on what your final code should look like (Coding Standard, Style Guide).\n\nHere you can find an overview of how your total grade for the KU will be calculated: [Procedure and Grading](https://www.notion.so/coding-tugraz/Procedure-and-Grading-59975fee4a9c4047867772cd20caf73d)\n\n### Submission\n- Deliverables: `a2.c`\n- Push to your repository\n- **Deadline: 6th December 2023, 23:59 (GMT+1)**\n\n## Assignment Description\n\nThis program simulates the operation of an arbitrary number of elevators in a hotel with an arbitrary number of floors.\nAt the beginning, the user provides the program with parameters including the hotel name, the number of floors, the number of elevators and the position and destination floors of the guests waiting for the elevators.\nThen, an illustration of the initial status of the elevators and guests is printed on the CLI (command line interface). \nSubsequently, the user can either start the simulation or terminate the program. \nThe simulation runs in steps and, for each step, elevators move one floor upwards or downwards. \nGuests can enter and leave the elevators on each floor.\nAn illustration of each step is printed in the CLI. \nThe simulation and, thus, the program are terminated once all the guests have arrived at their destination floor.\n\n### General Notes\nThe notes given in this section are important for the entire assignment description:\n\n- `\\n` shouldn't be printed as separate characters, instead they represent the newline character.\n- Note the leading and trailing spaces in the text fields! You can make them visible by selecting the text field.\n- Words in angle brackets (such as `\u003cHOTEL_NAME\u003e`) should be replaced by calculated or given data. They are *not* part of the output itself! For a better understanding, you can look at the example outputs at the very bottom of this document.\n- For each string-expected user input (marked with STRING in the title of the corresponding section), you can assume that an array of printable ASCII characters consisting of at least one character will be used. Other inputs like integers or non-printable characters will not be tested.\n- The user input is **case-insensitive**. This means that `YES`, `yes` and `yEs` would all be valid inputs.\n- For each integer-expected user input (marked with INT in the title of the corresponding section), you can assume that only integers will be used. You don't have to think about other inputs like characters or multiple integers separated by spaces. However, it is possible that values outside the valid integer range occur.\n- You can assume that the **integer input does not have any extra whitespaces**. For **string input, you do not have to ignore the whitespaces**, but treat them as part of the input string instead.\n- ` \u003e ` (command prompt, always printed with a leading and trailing space) in the output indicates that the program should wait for user input at this point. Execution should only continue after the user has ended their input with `ENTER`.\n- If the user's input is invalid, the corresponding error message should be printed (unless otherwise stated). After this, the question is asked again, the command prompt is printed, and the user can make a new input. This process is repeated as long as the input is invalid.\n- Take care with your memory management! That means that when allocating memory on the heap, you always need to check that the system was able to provide that memory. If the program runs out of memory you should first free all memory previously allocated on the heap, then print the correct error message (`Out of memory! Program terminated!\\n`) and terminate the program with the corresponding return value `-1`.\n\n## Program Sequence\n\n\n#### Welcome Message\n\nAt the beginning of the program, the user is welcomed with the following message:\n\n```\n____________________\\n\n ____   ____   ____ \\n\n|____  |____  |____|\\n\n|____   ____| |     \\n\n____________________\\n\n\\n\nWelcome to the\\n\nElevator Simulation Program!\\n\n\\n\n```\n\n### User Inputs (Data)\n\n---\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ch5\u003eUser Input: Hotel Name (STRING)\u003c/h5\u003e\u003c/summary\u003e\n\nThe user is first prompted for the name of the hotel:\n\n```\nEnter the name of the hotel:\\n\n \u003e \n```\nFor the sake of simplicity, you can assume that the user's input will always fit into the upper part of the hotel illustration. Names that are longer will not be tested. Check out the State Output section (Simulation \u003e Starting Phase \u003e State Output) for better understanding!\n\n\u003e **Note:** From now on, \u003cHOTEL_NAME\u003e should always be replaced by the hotel name the user specified printed in CAPITAL letters!\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ch5\u003eUser Input: Number of Floors (INT)\u003c/h5\u003e\u003c/summary\u003e\n\nThe user is prompted for the number of floors. The hotel must have at least 3 and no more than 10 floors. \n\n```\nEnter the number of floors in hotel \u003cHOTEL_NAME\u003e:\\n\n \u003e \n```\n\nIf the user input is invalid, the following error message will be printed:\n\n```\nWrong input, the number of floors must be between 3 and 10!\\n\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ch5\u003eUser Input: Number of Elevators (INT)\u003c/h5\u003e\u003c/summary\u003e\n\nNext, the user is prompted for the number of elevators. The hotel must have at least 1 and no more than 5 elevators. \n\n```\nEnter the number of elevators in hotel \u003cHOTEL_NAME\u003e:\\n\n \u003e \n```\n\nIf the user input is invalid, the following error message will be printed:\n\n```\nWrong input, the number of elevators must be between 1 and 5!\\n\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ch5\u003eUser Input: Elevator Capacity (INT)\u003c/h5\u003e\u003c/summary\u003e\n\nThe elevators have a certain capacity (number of people that can fit at the same time). This capacity is the same for all elevators in the hotel.\nAn elevator has a minimum capacity of 1 person and a maximum capacity of 9 people. The user is required to enter the elevator capacity as follows:\n\n```\nEnter the capacity of elevators in hotel \u003cHOTEL_NAME\u003e:\\n\n \u003e \n```\n\nIf the user input is invalid, the following error message will be printed:\n\n```\nWrong input, the capacity of elevators must be between 1 and 9 person(s)!\\n\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ch5\u003eUser Input: Number of Waiting People (INT)\u003c/h5\u003e\u003c/summary\u003e\n\nOn each floor, there is a number of people who are waiting for an elevator. For simplicity, this number is going to be the same for all floors.\nOn each floor, there are at least 2 and at most 20 people waiting for an elevator. The user is required to enter this number as follows:\n\n```\nEnter the number of people waiting on each floor:\\n\n \u003e \n```\n\nIf the user input is invalid, the following error message will be printed:\n\n```\nWrong input, the number of people waiting on each floor must be between 2 and 20!\\n\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ch5\u003eUser Input: Destination Floors\u003c/h5\u003e\u003c/summary\u003e\n\nFor each of the floors, the user is required to enter the destination floor of each person:\n\n```\nEnter the destination floors of the people [floor: \u003cFLOOR_NUMBER\u003e]:\\n\n \u003e \n```\nThe user needs to enter the destination floors as a comma-separated list of integers. For example, for the first floor of a hotel with 5 floors where 5 people are waiting on each floor, it could look like this:\n\n```\nEnter the destination floors of the people [floor: 1]:\\n\n \u003e 0,3,2,4,4\n```\nOnly a comma-separated list of integers is a valid input, and no other inputs will be tested. There are certain invalid input possibilities which you need to handle. Here is a table of possible violations and the corresponding messages:\n\n| Violation                                                             | Error Message |\n|-----------------------------------------------------------------------|------------|\n| Entered destination floor is out of range (0 to NUMBER_OF_FLOORS - 1) | ```Wrong input, the destination floor \u003cENTERED_FLOOR\u003e is out of range (0 to \u003cNUMBER_OF_FLOORS - 1\u003e)!\\n```       |\n| Entered destination floor is the current floor                            | ```Wrong input, the destination floor cannot be the current floor!\\n```       |\n\nFor simplicity, the list entered is always \u003cNUMBER_OF_PEOPLE_WAITING_ON_EACH_FLOOR\u003e long. Longer or shorter lists are not tested. \n\nThe input for a floor is each time read in its entirety, and each value is checked in the order it was entered, even if an error occurs. In such a case, a message is printed for each error. Then, the user is prompted to repeat the input for the current floor (`Enter the destination floors of ...`).\n\n\u003c/details\u003e\n\n### Simulation\n\n---\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ch4\u003eStarting Phase\u003c/h4\u003e\u003c/summary\u003e\n\nArrays shall be set up to store all the information about the hotel, the elevators and the guests. You are free to choose a configuration\nof arrays that suits your program, but they **must all be stored on the heap**.\n\nIf the memory allocation fails, the following error message should be printed:\n\n```\nOut of memory! Program terminated!\\n\n```\nThen, the program should terminate with the return value `-1` (see also Simulation \u003e Final Phase \u003e Return Values). All previously allocated memory must be freed before terminating the program.\n\n##### User Input: Show Initial State (STRING)\n\nAfter everything has been set up, the program should be ready to show an illustration of the initial state of the elevators and guests. \n\nFirst, the user is asked if they want to see it:\n\n```\nShow the initial state? (\"yes\"/\"no\"):\\n\n \u003e \n```\n\nValid inputs are `yes` or `no`. \nIf the user input is invalid, the program should **not** print an error message and just repeat the question and the command prompt until a valid command is entered.\n\nIf the answer is `yes`, the initial state is shown. If the answer is `no`, the program directly proceeds to execute the Running Phase (Simulation \u003e Running Phase).\n\nThe initial state is printed with the following header:\n\n```\n\\n\n=================\\n\n  INITIAL STATE\\n\n=================\\n\n\\n \n```\nIt is followed by the current (initial) State Output (Simulation \u003e Starting Phase \u003e State Output). Take a look at the example initial output to see what that looks like (Simulation \u003e Starting Phase \u003e Example Initial Output).\n\n##### State Output\n\nWhenever the state of the elevators is printed, it should look like this:\n\n```\n++-----------------++\\n\n++  \u003cHOTEL_NAME\u003e   ++\\n\n++-----+-----+-----++\\n\n||     |[\u003cP\u003e]|     ||  (\u003cD1\u003e,\u003cD2\u003e,\u003c...\u003e,\u003cDn\u003e)\\n\n||-   -+-   -+-   -||\\n\n||     |     |     ||  (\u003cD1\u003e,\u003cD2\u003e,\u003c...\u003e,\u003cDn\u003e)\\n\n||-   -+-   -+-   -||\\n\n||[\u003cP\u003e]|     |[\u003cP\u003e]||  (\u003cD1\u003e,\u003cD2\u003e,\u003c...\u003e,\u003cDn\u003e)\\n\n++-----+-----+-----++\\n\nElevators:\\n\n0: (\u003cED1\u003e,\u003cED2\u003e,\u003c...\u003e,\u003cEDec\u003e)\\n\n1: (\u003cED1\u003e,\u003cED2\u003e,\u003c...\u003e,\u003cEDec\u003e)\\n\n2: (\u003cED1\u003e,\u003cED2\u003e,\u003c...\u003e,\u003cEDec\u003e)\\n\n\\n\n```\n\nIf all the elevators are empty, the section starting with ```Elevators:\\n``` is not printed. In this case, only the hotel illustration is printed. The state output would then look like this:\n  ```\n  ++-----------------++\\n\n  ++  \u003cHOTEL_NAME\u003e   ++\\n\n  ++-----+-----+-----++\\n\n  ||     |[\u003cP\u003e]|     ||  (\u003cD1\u003e,\u003cD2\u003e,\u003c...\u003e,\u003cDn\u003e)\\n\n  ||-   -+-   -+-   -||\\n\n  ||     |     |     ||  (\u003cD1\u003e,\u003cD2\u003e,\u003c...\u003e,\u003cDn\u003e)\\n\n  ||-   -+-   -+-   -||\\n\n  ||[\u003cP\u003e]|     |[\u003cP\u003e]||  (\u003cD1\u003e,\u003cD2\u003e,\u003c...\u003e,\u003cDn\u003e)\\n\n  ++-----+-----+-----++\\n\n  \\n\n  ```\n\u003e **Note:** : The hotel illustration depends on the number of elevators and floors. In the example above, we have 3 elevators and 3 floors. For the other hotel sizes, the illustration should be extended accordingly (see Example Outputs).\n\n- Elevators are represented with `[\u003cP\u003e]`. `\u003cP\u003e` should be replaced by the number of people currently in the elevator.\n- Elevators are numbered from left to right, starting with 0. This is visible in the elevator lists following the hotel illustration whenever there are people in the elevators.\n- Each elevator has a fixed starting position. Elevators with even numbers have their starting position on the GROUND floor and will start going UPWARDS once the simulation starts.\nElevators with odd numbers start at the TOP floor and will start going DOWNWARDS once the simulation starts.\n- The list of waiting people is printed in brackets to the right of each floor. The placeholders `\u003cD1\u003e` to `\u003cDn\u003e` are replaced with the destination floors of the waiting people. The index \"n\" represents the number of people waiting on each floor.  \n  \u003e **Attention:** The list is sorted in **ascending** order of the destination floors. People who have already left their starting floor are shown in the list of waiting people with the symbol `-`, and these are printed before the waiting persons: ```(-,-,\u003cDx\u003e,\u003c...\u003e,\u003cDz\u003e)``` (see Example Outputs).\n- The hotel name is centered in the top segment of the output. If an exact alignment is not possible, the hotel name starts one space to the left.\n- If there are any people in the elevators, the list of elevators is printed with the list of people in them. The placeholders `\u003cED1\u003e` to `\u003cEDec\u003e` are replaced with the destination floors of the people currently in the elevator. The index \"ec\" represents the elevator capacity.\n  \u003e **Attention:** The list is sorted in **ascending** order of the destination floors. For the empty places in the elevator, the symbol `-` is printed. Empty places are printed before taken places.\n\n##### Example Initial Output\n\nFor example, for a simple hotel with 5 floors and 3 elevators, with 5 guests on each floor, the initial state may look like this:\n\n```\n\\n\n=================\\n\n  INITIAL STATE\\n\n=================\\n\n\\n \n++-----------------++\\n\n++   SIMPLEHOTEL   ++\\n\n++-----+-----+-----++\\n\n||     | [0] |     ||  (0,1,2,2,3)\\n\n||-   -+-   -+-   -||\\n\n||     |     |     ||  (0,0,1,1,4)\\n\n||-   -+-   -+-   -||\\n\n||     |     |     ||  (0,1,3,3,4)\\n\n||-   -+-   -+-   -||\\n\n||     |     |     ||  (0,0,2,4,4)\\n\n||-   -+-   -+-   -||\\n\n|| [0] |     | [0] ||  (1,1,2,2,3)\\n\n++-----+-----+-----++\\n\n\\n\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ch4\u003eRunning Phase\u003c/h4\u003e\u003c/summary\u003e\n\n##### User Input: Start Simulation (STRING)\n\nAfter the input data has been provided to the program and, optionally, the initial state has been shown, the user is asked if they want to start the simulation:\n\n```\nStart the simulation? (\"start\"/\"skip\"):\\n\n \u003e \n```\nValid inputs are `start` or `skip`. \nIf the user input is invalid, the program should **not** print an error message and just repeat the question and the command prompt until a valid command is entered.\n\nIf the input is `skip`, the program terminates with the return value `0` (see Simulation \u003e Final Phase \u003e Return Values).\nIf the input is `start`, the program continues with the next step. \n\n##### User Input: Results Display Options (STRING)\n\nThe user has the option to view an illustration of the hotel for each step of the simulation, or just the end result:\n\n```\nShow all steps of the simulation? (\"all steps\"/\"end result\"):\\n\n \u003e \n```\n\nValid inputs are `all steps` or `end result`. If the user input is invalid, the program should **not**\nprint an error message and just repeat the question and the command prompt until a valid command is entered.\n\n##### Simulation Steps\n\nThe simulation runs in steps until all people have arrived at their destination floors. There is a simulation step counter which starts at `0` (for the initial state).\n\nEach step of the simulation is executed in the following order: \n\n- The simulation step counter is increased by `1`. \n- If the user has chosen to show all steps, a step header with the number of the current step is printed:\n```\n=== Simulation Step \u003cSTEP_COUNTER\u003e ===\\n\n```\n- For each of the elevators (starting from the elevator number 0), the following procedure occurs:\n\n  - If there are people in the elevator whose destination floor is the current floor, the people leave the elevator. These people are no longer needed in the rest of the program, so they can be deleted. For each of them the following message is printed:\n    ```\n    A person reached their destination floor \u003cCURRENT_FLOOR\u003e with elevator \u003cELEVATOR_NUMBER\u003e.\\n\n    ```\n  - People waiting on the current floor enter the elevator if their destination floor is in the current direction (up or down) of the elevator. People can only enter the elevator until the maximum capacity is reached.\n  If there are more people meeting the specified criteria waiting for the elevator than the elevator can carry, those closest to their destination floors will board first. If multiple people have the same shortest distance and the elevator reaches its maximum capacity, the decision of who gets on and who waits can be made freely.\n- Once the procedure is completed for all elevators, if the user has opted to display all steps, the current state is presented as outlined in State Output (Simulation \u003e Starting Phase \u003e State Output).\n\n  For example:\n  ``` \n  ++-----------------++\\n\n  ++   SIMPLEHOTEL   ++\\n\n  ++-----+-----+-----++\\n\n  ||     |     |     ||  (-,-,-,0,1)\\n\n  ||-   -+-   -+-   -||\\n\n  ||     | [3] |     ||  (-,0,0,1,4)\\n\n  ||-   -+-   -+-   -||\\n\n  ||     |     |     ||  (0,1,3,3,4)\\n\n  ||-   -+-   -+-   -||\\n\n  || [3] |     | [3] ||  (-,-,-,0,0)\\n\n  ||-   -+-   -+-   -||\\n\n  ||     |     |     ||  (-,-,-,-,-)\\n\n  ++-----+-----+-----++\\n\n  Elevators:\\n\n  0: (2,2,4)\\n\n  1: (1,2,2)\\n\n  2: (2,3,4)\\n\n  \\n\n  ```\n- If all people have reached their destination floor, the simulation ends (see Simulation \u003e Final Phase). Otherwise, for each of the elevators, the following occurs:\n\n  - The elevator moves one floor in its current direction (UPWARDS/DOWNWARDS).\n  - If an elevator is now on the GROUND/TOP floor, it changes direction.\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ch4\u003eFinal Phase\u003c/h4\u003e\u003c/summary\u003e\n\nThe simulation terminates immediately after all people have reached their destination floors.\nNow, the final state of the elevators should be shown as described in State Output (Simulation \u003e Starting Phase \u003e State Output). \nThis final state is always printed, independently of whether the user has chosen to show all steps.\nThe list of elevators below the hotel illustration is not printed anymore, because all elevators are empty.\n\nThe final state is printed with this header:\n```\n\\n\n=================\\n\n   FINAL STATE\\n\n=================\\n\n\\n\n```\nIt is followed by the current (final) state (see Simulation \u003e Starting Phase \u003e State Output).\n\nFor example:\n``` \n\\n\n=================\\n\n   FINAL STATE\\n\n=================\\n\n\\n \n++-----------------++\\n\n++   SIMPLEHOTEL   ++\\n\n++-----+-----+-----++\\n\n||     |     |     ||  (-,-,-,-,-)\\n\n||-   -+-   -+-   -||\\n\n||     | [0] |     ||  (-,-,-,-,-)\\n\n||-   -+-   -+-   -||\\n\n||     |     |     ||  (-,-,-,-,-)\\n\n||-   -+-   -+-   -||\\n\n|| [0] |     | [0] ||  (-,-,-,-,-)\\n\n||-   -+-   -+-   -||\\n\n||     |     |     ||  (-,-,-,-,-)\\n\n++-----+-----+-----++\\n\n\\n\n```\nAfter that the following message is printed:\n```\nSimulation done in \u003cNUMBER_OF_STEPS_THE_SIMULATION_TOOK\u003e steps!\\n\n```\n\nAfterwards, the program should terminate and **return the number of steps taken by the simulation**. \n\n### Return Values\n\nHere is an overview of the expected return values of the program:\n\n|             Scenario              |        Return value        |\n|:---------------------------------:|:--------------------------:|\n| Memory allocation error occurred  |             -1             |\n|      Simulation not started       |             0              |\n| Simulation completed successfully | Number of simulation steps |\n\n\u003c/details\u003e\n\n### Example Outputs\n\n---\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ch4\u003eExample 1\u003c/h4\u003e\u003c/summary\u003e\n\n```\n____________________\n ____   ____   ____ \n|____  |____  |____|\n|____   ____| |     \n____________________\n\nWelcome to the\nElevator Simulation Program!\n\nEnter the name of the hotel:\n \u003e RepeatInPUtHotEl\nEnter the number of floors in hotel REPEATINPUTHOTEL:\n \u003e 0\nWrong input, the number of floors must be between 3 and 10!\nEnter the number of floors in hotel REPEATINPUTHOTEL:\n \u003e 3\nEnter the number of elevators in hotel REPEATINPUTHOTEL:\n \u003e 9\nWrong input, the number of elevators must be between 1 and 5!\nEnter the number of elevators in hotel REPEATINPUTHOTEL:\n \u003e 3\nEnter the capacity of elevators in hotel REPEATINPUTHOTEL:\n \u003e 1\nEnter the number of people waiting on each floor:\n \u003e 200\nWrong input, the number of people waiting on each floor must be between 2 and 20!\nEnter the number of people waiting on each floor:\n \u003e 2\nEnter the destination floors of the people [floor: 0]:\n \u003e 3,4\nWrong input, the destination floor 3 is out of range (0 to 2)!\nWrong input, the destination floor 4 is out of range (0 to 2)!\nEnter the destination floors of the people [floor: 0]:\n \u003e 0,0\nWrong input, the destination floor cannot be the current floor!\nWrong input, the destination floor cannot be the current floor!\nEnter the destination floors of the people [floor: 0]:\n \u003e 1,2\nEnter the destination floors of the people [floor: 1]:\n \u003e 0,2\nEnter the destination floors of the people [floor: 2]:\n \u003e 0,1\nShow the initial state? (\"yes\"/\"no\"):\n \u003e yey\nShow the initial state? (\"yes\"/\"no\"):\n \u003e yes\n\n=================\n  INITIAL STATE\n=================\n\n++-----------------++\n++REPEATINPUTHOTEL ++\n++-----+-----+-----++\n||     | [0] |     ||  (0,1)\n||-   -+-   -+-   -||\n||     |     |     ||  (0,2)\n||-   -+-   -+-   -||\n|| [0] |     | [0] ||  (1,2)\n++-----+-----+-----++\n\nStart the simulation? (\"start\"/\"skip\"):\n \u003e strt\nStart the simulation? (\"start\"/\"skip\"):\n \u003e start\nShow all steps of the simulation? (\"all steps\"/\"end result\"):\n \u003e end\nShow all steps of the simulation? (\"all steps\"/\"end result\"):\n \u003e end result\nA person reached their destination floor 1 with elevator 0.\nA person reached their destination floor 1 with elevator 1.\nA person reached their destination floor 2 with elevator 0.\nA person reached their destination floor 0 with elevator 1.\nA person reached their destination floor 2 with elevator 2.\nA person reached their destination floor 0 with elevator 0.\n\n=================\n   FINAL STATE\n=================\n\n++-----------------++\n++REPEATINPUTHOTEL ++\n++-----+-----+-----++\n||     | [0] |     ||  (-,-)\n||-   -+-   -+-   -||\n||     |     |     ||  (-,-)\n||-   -+-   -+-   -||\n|| [0] |     | [0] ||  (-,-)\n++-----+-----+-----++\n\nSimulation done in 5 steps!\n```\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ch4\u003eExample 2\u003c/h4\u003e\u003c/summary\u003e\n\n```\n____________________\n ____   ____   ____ \n|____  |____  |____|\n|____   ____| |     \n____________________\n\nWelcome to the\nElevator Simulation Program!\n\nEnter the name of the hotel:\n \u003e hOtel\nEnter the number of floors in hotel HOTEL:\n \u003e 3\nEnter the number of elevators in hotel HOTEL:\n \u003e 2\nEnter the capacity of elevators in hotel HOTEL:\n \u003e 1\nEnter the number of people waiting on each floor:\n \u003e 2\nEnter the destination floors of the people [floor: 0]:\n \u003e 1,2\nEnter the destination floors of the people [floor: 1]:\n \u003e 0,2\nEnter the destination floors of the people [floor: 2]:\n \u003e 0,1\nShow the initial state? (\"yes\"/\"no\"):\n \u003e yes\n\n=================\n  INITIAL STATE\n=================\n\n++-----------++\n++   HOTEL   ++\n++-----+-----++\n||     | [0] ||  (0,1)\n||-   -+-   -||\n||     |     ||  (0,2)\n||-   -+-   -||\n|| [0] |     ||  (1,2)\n++-----+-----++\n\nStart the simulation? (\"start\"/\"skip\"):\n \u003e start\nShow all steps of the simulation? (\"all steps\"/\"end result\"):\n \u003e all steps\n=== Simulation Step 1 ===\n++-----------++\n++   HOTEL   ++\n++-----+-----++\n||     | [1] ||  (-,0)\n||-   -+-   -||\n||     |     ||  (0,2)\n||-   -+-   -||\n|| [1] |     ||  (-,2)\n++-----+-----++\nElevators:\n0: (1)\n1: (1)\n\n=== Simulation Step 2 ===\nA person reached their destination floor 1 with elevator 0.\nA person reached their destination floor 1 with elevator 1.\n++-----------++\n++   HOTEL   ++\n++-----+-----++\n||     |     ||  (-,0)\n||-   -+-   -||\n|| [1] | [1] ||  (-,-)\n||-   -+-   -||\n||     |     ||  (-,2)\n++-----+-----++\nElevators:\n0: (2)\n1: (0)\n\n=== Simulation Step 3 ===\nA person reached their destination floor 2 with elevator 0.\nA person reached their destination floor 0 with elevator 1.\n++-----------++\n++   HOTEL   ++\n++-----+-----++\n|| [1] |     ||  (-,-)\n||-   -+-   -||\n||     |     ||  (-,-)\n||-   -+-   -||\n||     | [1] ||  (-,-)\n++-----+-----++\nElevators:\n0: (0)\n1: (2)\n\n=== Simulation Step 4 ===\n++-----------++\n++   HOTEL   ++\n++-----+-----++\n||     |     ||  (-,-)\n||-   -+-   -||\n|| [1] | [1] ||  (-,-)\n||-   -+-   -||\n||     |     ||  (-,-)\n++-----+-----++\nElevators:\n0: (0)\n1: (2)\n\n=== Simulation Step 5 ===\nA person reached their destination floor 0 with elevator 0.\nA person reached their destination floor 2 with elevator 1.\n++-----------++\n++   HOTEL   ++\n++-----+-----++\n||     | [0] ||  (-,-)\n||-   -+-   -||\n||     |     ||  (-,-)\n||-   -+-   -||\n|| [0] |     ||  (-,-)\n++-----+-----++\n\n\n=================\n   FINAL STATE\n=================\n\n++-----------++\n++   HOTEL   ++\n++-----+-----++\n||     | [0] ||  (-,-)\n||-   -+-   -||\n||     |     ||  (-,-)\n||-   -+-   -||\n|| [0] |     ||  (-,-)\n++-----+-----++\n\nSimulation done in 5 steps!\n```\n\u003c/details\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenji377%2Ftug-introductiontoc-02","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbenji377%2Ftug-introductiontoc-02","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbenji377%2Ftug-introductiontoc-02/lists"}