Question: Program: ship _ planner.py For this exam, you will need to write a program that can keep track of the composition of a container ship
Program: shipplanner.py
For this exam, you will need to write a program that can keep track of the composition of a container
ship and its cargo. Your program will compute the speed and draught of potential container ship
configurations. You will need to write two classes to represent the container ship, the containers that
carry the cargo.
Class: Container
An intermodal container or shipping container is a standardized container design that can be used
across different modes of transport, from ship to rail to truck, without unloading and reloading their
cargo. A container can come in two standard sizes: TEU and TEU. The container class should store
information about the specifications of each container: size and cargo type.
Size The size of the container: TEU or TEU
Cargo Type The type of cargo being carried:
o Frozen Food FF
o Consumer Goods CG
o Processed Goods PG
o Raw Materials RM
o Industrial Equipment IE
Your container class must implement methods to get the size and cargo type:
getsize Returns the size of the container in TEU.
getcargotype Returns the type of cargo.
Class: Container Ship
A container ship is a type of cargo ship that carries all its cargo in trucksized containers. A container
ships capacity is measured in twentyfoot equivalent units TEU Typically, a container ships cargo is
split between foot TEU and foot TEU containers. The constructor for your container ship
class will take the following parameters as input:
Maximum Capacity The maximum number cargo capacity of the container ship in TEUs.
Maximum Speed The maximum speed the container ship can sail with no cargo in nautical
miles per hour knots
Minimum Draft The minimum depth of the container ship with no cargo in meters.
Maximum Draft The maximum depth of the container ship with full cargo in meters.
Your container ship class should store a list of all the containers assigned to the cargo ship into an
attribute called containers. The draft of the ship is dependent on the current cargo of the ship and its
maximum capacity. The ships draft increases linearly as its capacity increases up to its maximum
capacity. The speed of the ship is dependent on its maximum speed and its current draft. The ships
speed decreases linearly as its draft increases up to its maximum draft. The minimum speed of the ship
is of its maximum speed when at its maximum draft.
The following attributes of the container ship class should be calculated from the list of containers:
Cargo The amount of cargo assigned to the container ship in TEUs.
Draft The depth of the container ship given its current cargo and maximum capacity.
Speed The speed of the container ship given its current draft.
Your container ship class must implement methods to get the capacity, draft, and speed for all objects of
the container ship class:
getcargo Returns the capacity a TEUs.
getdraft Returns the draft of the container ship in meters.
getspeed Returns the speed of the container in knots.
Your container ship class must implement methods to add and remove containers from the ship:
addcontainer container Adds the input container to the top of the container ship if the
container does not cause the ship to exceed its maximum capacity.
removecontainer Removes the container at the top of the container ship.
Your container ship class must implement a method to print out the composition of the ship:
printship Prints the following information about the planned cargo of the ship:
o Cargo The amount of cargo that has been filled in TEUs.
o Draft Depth of the containership given its current cargo in meters.
o Speed The speed of the container ship given its current draft in knots.
o Composition Letter abbreviation for the cargo for each container split across rows.
Containers can be stacked to a maximum height of Cargo is loaded bottom up See
Example Output
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
