The program that you are writing for this assignment is a software simulation for a harbour. The harbour has ships coming and going. A ship comes into the harbour with a load on it. After docking, the ship must be unloaded and then sent on its way. A ship can only dock in a bay that is at least as large enough to hold it at maximum capacity.
A harbour has a certain number of docking bays that can be used by ships to dock at. Each docking bay has a maximun load size that it can hold. It also has a time it takes to unload a ship of that maximum size.
Your program will read from 2 different files. One file will contain all the details about the harbour and its docking bays. The second file will contain all the details about the ships that are going to dock at the harbour.
Each harbour has a fixed number of docking bays. Each docking bay has a unique ID number, a maximum size ship it can hold, a time it takes to unload the ship when it is at full capacity, and a charge per unit it unloads.
Each ship has a unique ID number, a maximum number of capacity, an actual capacity, and an arrival time.
When a ship docks it can only be docked into a bay that is equal to or larger than its maximum capacity. Each ship is processed into a docking bay in the order it arrives but may need to wait for a docking bay big enough to hold it to become free. In this case, if there are ships that arrive after it they may be processed before it, if there are free docking bays that can accommodate the other ship's maximum capacity.
Your program must process the ships, assigning them to the appropriate docking bay, unload their cargo, and then move them out of the docking bay. A bay is only free 2 time units after the last cargo container has been removed from the ship.
You must output the capacity that the harbour is working at, the total amount of money it collected from unloading the ships and the total number of ships it unloaded.
The harbour file will be in the following format: the first line will contain an integer that tells you how many docking bays the harbour contains followed by a string which will be the name of the harbour. Each line after that will contain the information about each docking bay: an integer representing the unique ID, an integer representing the maximum size ship it can hold, an itneger representing how many time units it takes to unload a ship at full capacity and a double representing the amount of money charged per unit it unloads.
An example file. See image.
The first line will contain an integer that tells you how many ships you will process. Each line after that will contain the information about each ship: an integer representing the ship's unique ID, an integer representing the ship's maximum capacity, an integer represting actual capacity of the ship and an integer representing the time of arrival. See image.
You will need to open the two files and read information from them. The information from each file should be loaded into structures. Use a structure for each docking bay and another structure to represent each boat. Arrays and dynamic memory allocation is needed.
I suggest breaking the program into several functions as this will enable you to test your program function by function.
The output of your program needs to be structured in a manner that is easily readable. You may want to output it in a table format. The output will be displayed on screen and written to a file. Please ensure that it is easily readable and understandable for the user.