Exercise: Warehouse Item
Practice how to implement a warehouse management program using the State pattern.
We'll cover the following...
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 thestoredstate and recordslocationIdwhere it’s stored.deliver(address)changes the state of the item todelivered, sets the delivery address, and clearslocationId.describe()returns a string representation of the current state of the item (for ...