zpervan / GasStation

Gas station simulation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Gas station simulation

Linux

Gas station simulation created with C++ and Bazel in Linux Ubuntu.

Setup

  1. Open your terminal and navigate to the root of the project
  2. Allow execution permissions to the installation and execute the following:
~/GasStation$ sudo chmod +x Scripts/ubuntu_install.sh
  1. Now you can execute the installation script and install all needed dependencies. Do this with the following command:
~/GasStation$ sudo ./Scripts/ubuntu_install.sh
  1. And you're ready to go

Run

  1. Open your terminal and navigate to the root of the project
  2. To run the project, execute the following command:
~/GasStation$ bazel run //Code:main -c dbg # Debug mode OR
~/GasStation$ bazel run //Code:main -c opt # Release mode (preferred)
  1. And the application output should be visible in the console

Assignment decomposition

We have 2 gas pumps and 10 cars waiting in queue to fill up.

      ___   +-----+         ___    +-----+
     O   O  |  G  |        O   O   |  G  |
     | C |  |  P  |        | C |   |  P  |
     | 0 |  |  0  |        | 1 |   |  1  |
     O___O  +-----+        O___O   +-----+
         
                \               /
                 \             /
                  \    ___    /
                      O   O  
                      | C |  
                      | 3 |  
                      O___O  
                        .
                        .
                        .
                       ___   
                      O   O   
                      | C |  
                      | 9 |  
                      O___O  

Each car can fill up once and then goes back to line, which means that it CANNOT fill up again on the other pump in the same turn. After each fill up is finished, we increase the fill up count for both cars and gas pumps. We do this for 30 seconds and print out the statistics to the console.

About

Gas station simulation


Languages

Language:C++ 85.9%Language:Shell 9.3%Language:Starlark 4.8%