Exercise: Warehouse Item
Practice how to implement a warehouse management program using the State pattern.
We'll cover the following...
Problem statement
Imagine we’re working on a warehouse management program. Our next task is to create a class to model a warehouse item and help track it. Such a WarehouseItem
class has a constructor, which accepts an id
and the initial state
of the item (which can be one of arriving
, stored
, or delivered
). It has three public methods:
store(locationId)
moves the item into thestored
state and recordslocationId
where it’s stored.deliver(address)
changes the state of the item todelivered
, sets the delivery ...