Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: THEend8_
CAB340 Assessment 2 Stream ciphers
Introduction
In this assignment, you will continue developing a simple simulation of a cargo port system, build-
ing on the core model of the system you implemented in assignment one.
In assignment two, additional logic is added to the Port class to process the movements that are
queued to be executed. Movements will now be actioned by the port when their action time is
reached, moving cargo and ships in and out of the port.
The concept of time is introduced to the simulation. One tick in the simulation represents a minute
in real life. The Tickable interface allows classes to specify behaviour that occurs on each simu-
lation tick.
The StatisticsEvaluator abstract class provides a way to monitor various statistics relating to
the port’s operations. Four subclasses of StatisticsEvaluator are to be implemented, which
gather and report data on the cargo and ships that have moved through the port. More subclasses
could be implemented in future to provide more insights into the collected data.
Ships that are arriving at the port must wait in a ShipQueue before being allocated a quay to dock
at. The ShipQueue prioritises inbound ships based on a set of rules that check each ship’s current
status. For example, ships carrying dangerous cargo must be docked before any other ship waiting
in the queue.
To ensure that each Cargo and Ship instance must have a unique cargo ID and IMO number
respectively, the concept of the cargo/ship registry is introduced. These registries are a global
mapping of IDs/IMO numbers to Cargo/Ship instances, where duplicate keys are not allowed.
Each new Cargo/Ship instance registers itself with its registry inside the respective constructor.
To facilitate saving and loading the state of the simulation to and from a file, the Encodable in-
terface has been introduced. Any class implementing this interface must implement the encode()
method, which encodes the current state of the class to a machine-readable string. Similarly,
classes that can be encoded can also be decoded from a string to a class instance through their
fromString() method.
Many classes now override the default equals() and hashCode() method implementations inher-
ited from Object, allowing instances to be checked for equality according to their internal state.
A Graphical User Interface (GUI) using JavaFX has been provided in the portsim.display pack-
age. Note that the GUI will not work correctly until the other parts of the assignment it relies on
have been implemented. The GUI consists of three classes: View is responsible for creating the
visual elements displayed on screen, PortCanvas handles the graphics and drawing of the port in
the main canvas, while ViewModel manages interaction between the View and the core classes of
the model (e.g. Port). The Launcher class in the portsim package initialises the GUI and passes
the save file to the ViewModel.
While most of the GUI code has been provided to you, several methods must be implemented
to complete the GUI. These are the methods marked with \Implement this for assignment 2″ in
ViewModel { you do not (and should not) need to modify any code in View or PortCanvas.
Two examples have been provided of the save files used by the GUI to load the saved port simula-
tion. These files are saves/default.txt and saves/large.txt, representing an empty port and
a busy port with several ships, quays and queued movements respectively.