You are invited to Pie company that succeeds in baking and packing Pies. Their current infrastructure is described in the code:
// Different Bakeries that should be packed to Box'es and delivered to customers
class Bakery {}
class Cake extends Bakery {}
class Pie extends Bakery {}
class Tart extends Bakery {}
// This (of course) can be packed in a box, but we want to disable its delivery to customers
class Paper {}
// Implementing class exists that is used to pack everything
interface Box<T> {
public void put(T item);
public T get();
}
Now they decided to deliver bakeries to the customers and ask you to design the Deliveryman class. The delivery men should succeed in the following:
- Deliver Bakery or any subclass of it, packed into boxes
- Do not deliver anything else (e.g. Paper)
- Prohibit Deliveryman to put anything into the Box inside deliver method at a compile time by raising errors or warnings.
Your task is to create a method signature leaving implementation unchanged. The Deliveryman template follows:
public class Deliveryman {
// Method to change signature of
public void deliver(Box box) {
// He knows how to do this, leave unchanged
}
}
So, instead of public void deliver(Box box) write the line that replaces it in the field below.