Ships arrive at a port and drop anchor in an area just outside the port entrance
ID: 3920387 • 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
SOLUTION:
According to the given data the below illustrates that the dispatch and anchorage follows;
The below are the key classes :
A)Ship Class
B)priority linked list class
àShip Class :
In this ,the ship class models the ship data. Here,The ship class contains the additional details like "type of cargo", "priority", "arrival time" , "leave anchorage time", "enter port time" fields. The ship class has relevant getters and setters,and then Apart from this it has functions for deciding the priority of the ship based on the the type of the cargo.
àPrority linked list class :
Priority linked list class models has the ships waiting at the achorage.thus ,They will have add, delete functions. Therefore The nodes contain the ship data and link. Here,the Ship data is represented by ship class.Therefore dispatch rules will be followed while entering data in the list.Therefore the node that is present at the initial of the list will be serviced according to the dispatch rules.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.