A menu-driven supply chain logistics simulator built in C++ for our 2nd semester Object Oriented Programming course at FAST-NUCES Karachi.
- Create and manage shipment orders.
- Load cargo crates onto transport vehicles (trucks, planes, ships, drones).
- Dispatch shipments and track their status with calculated transit times.
- Run customs audits for international shipments (checks for hazmat and fragile rules).
- Save and load the system state to text files using custom File I/O.
The program runs in a command-line loop. You start by adding some vehicles to your fleet. Once you have a fleet, you can create cargo crates and assign them to shipment orders.
When you try to load crates onto a vehicle, the system checks several rules. For example, drones can't carry over 50kg per crate, planes can't take hazmat materials, and ships can't take fragile items. If a rule is broken, it blocks the load. When you dispatch a shipment, it calculates the transit time based on the vehicle's speed and the distance. We also added a customs auditor for international orders that flags banned materials and calculates tariffs. You can save all your active data to text files and load it back up later.
- Inheritance:
GroundTransport,AirTransport, andWaterTransportinherit from an abstractTransportAssetbase class. We also used multiple virtual inheritance for theHeavyLiftDroneso it can act as both air and ground transport without hitting the diamond problem. - Polymorphism: We used pure virtual functions (like
calculateTransitTime()andloadCrate()) so each vehicle type runs its own specific logic. - Templates: Instead of relying on
<vector>, we built a customRegistry<T>template class to manage our dynamic arrays of pointers. - Exception Handling: We made a custom exception hierarchy starting with
LogisticsExceptionto handle things like exceeding payload capacity or violating cargo rules. - Operator Overloading: We overloaded
operator+to handle capacity checks when loading crates, andoperator[]for easy array indexing. - Friend Classes: The
CustomsAuditoris a friend class toShipmentOrder, which lets it check the private crate arrays directly without opening up security holes with public setters.
- Compile: Open your terminal (VS Code Terminal, Command Prompt, or PowerShell) and run:
g++ Main.cpp Assets.cpp Logistics.cpp -o Logistics - Run on Windows (Default): In that same terminal, execute the program by typing
Logistics.exe(if using Command Prompt) or.\Logistics.exe(if using PowerShell or VS Code). - Run on Linux/macOS: Before compiling, open
Main.cppand replacesystem("cls")withsystem("clear"). Then compile and run using./Logistics.