Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Ships arrive at a port and drop anchor in an area just outside the port entrance

ID: 3865428 • Letter: S

Question

Ships arrive at a port and drop anchor in an area just outside the port entrance. This area is known as an anchorage. The ships wait at the anchorage until they are given a berth dispatch assignment, which includes the time at which a ship can leave the anchorage and enter the port. Each ship has a priority assigned to it based upon the type of cargo it is carrying. Priority values are integers and range from 0 to 10, with 10 corresponding to the highest priority. If ships have the same priority, then the ship with the earliest arrival time is dispatched to a berth first.

Assume you had to write an application that simulated the arrival and dispatch of ships at a port according to the above criteria. How would you model the anchorage and implement the dispatching rules? You must describe all the key classes that would be used in your solution.

Explanation / Answer

Modelling the achorage and implementing dispatch rules:

The key classes are as follows:

1.Priority Linked list Class
2.Ship class


Prority linked list class -- This class models the ships waiting at the achorage.This will have add, delete functions. The nodes contain the ship data and link. Ship data is represented by ship class.The dispatch rules will be followed while entering data in the list. Which node will be present at the begining the list to be serviced first will depend on the dispatch rules.

Ship Class - This class models the ship data. The ship class along with other details will be containing "type of cargo", "priority", "arrival time" , "leave anchorage time", "enter port time" fields. It has relevant getters and setters. Apart from this it has functions for deciding the priority of the ship based on the the type of the cargo.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote