A shipping desk prints labels for orders. Each order belongs to a customer, and each customer has an address, but a customer may decline to have their location shown.
Refactor the legacy ShippingDesk implementation while preserving this public API:
ShippingDesk() creates a desk with no customers and no orders.int addCustomer(String fullName, String city, String country, boolean sharesLocation) adds a customer and returns the id it was stored at.int placeOrder(int customerId, double amount) records an order for that customer and returns the order id, or -1 when the customer id is unknown.String label(int orderId) returns "<displayName> - <location>", or "UNKNOWN" when the order id is unknown.String summary(int orderId) returns "#<orderId> <label> (<amount>)" with the amount to two decimals, or "UNKNOWN" when the order id is unknown.int orderCount() returns how many orders exist.A customer's display name is the first initial, a full stop, a space and the last word of the full name, so Alice Smith shows as A. Smith. A single-word name is shown as it is.
A customer's location is "<city>, <country>" when they share it, and "WITHHELD" when they do not.
The starter exposes every nested object and has the desk walk from an order to its customer and then to the customer's address. That path bypasses the sharing decision and leaks locations marked private.
ShippingDesk is the only type the tests call, but it should not own every rule. Refactor the object graph so the desk asks an order for its label, the order asks its customer, and only the customer decides whether its address may be shown.
Input:
Output:
Explanation: A customer who shares their location has it shown, and the name is abbreviated by the customer rather than printed raw.
Input:
Output:
Explanation: A customer who does not share their location shows WITHHELD, because the customer decides and nothing reaches past it.
1 <= fullName.length <= 401 <= city.length <= 20 and 1 <= country.length <= 200 <= amount <= 10^6100 calls will be made across all methods.The starter compiles, but its getter chain exposes a private location. Remove the train wreck instead of adding another privacy check to the desk.
Full marks when the desk asks an order for its label, the order asks its customer, and only the customer touches the address. Lose points heavily when the desk or the order reads a customer's address directly, or when a getter chain such as order.customer().address().city() appears anywhere.
Full marks when the sharing decision lives on the customer and the abbreviation of the name lives there too, so no caller can produce a label that bypasses either. Lose points when the desk checks a sharing flag itself, or when the name is shortened outside the customer.
Full marks for an address that formats only itself, an unknown order id handled deliberately, and a summary built from the label rather than rebuilt. Lose points for printing to stdout or for the label format appearing in more than one place.
Passing every test is not enough on its own. A submission is accepted only when the design also clears the bar.
| Call | Returns |
|---|---|
| new ShippingDesk() | null |
| addCustomer("Alice Smith", "London", "UK", true) | 0 |
| placeOrder(0, 49.5) | 0 |
| label(0) | "A. Smith - London, UK" |
| summary(0) | "#0 A. Smith - London, UK (49.50)" |
| orderCount() | 1 |
A customer who shares their location has it shown, and the name is abbreviated by the customer rather than printed raw.
Run checks these cases. Submit also runs a larger hidden set.

