I'm reading Robert Sedgewick's Algorithms book and I often see the term API client. Please take a look at this exercise:
Write an iterable Stack client that has a static method copy() that takes a stack of strings as argument and returns a copy of the stack. Note : This ability is a prime example of the value of having an iterator, because it allows development of such functionality without changing the basic API.
I'm confused as to whether he wants me to implement the Stack API by creating a concrete class that implements Stack or he wants me to write a program that uses the Stack API functionality. So does he want this
class StackImpl implements Stack<Item>{
}
or this?
public static void main(String[] args){
Stack<String> stack = new Stack<String>();
stack.push("to");
stack.push("be");
stack.push("or");
stack.push("not");
System.out.println(copy(stack));
}
public static Stack<String> copy(Stack<String> stack){
//copy from stack to a new stack and return
}