Well, is there a better way to extract two tokens than by calling GetToken twice, it seems inappropriate, because one of your requirements:
(the class must have) a method that subtracts exactly one token from your number of tokens
So it seems you are stuck in two challenges. Since this is a very clever task, you can just stick to the requirements. If you really want to learn something, start your own personal project. :)
Also, as an aside, you can associate constructors with C #. So:
public TokenGiver() { numTokens = 0; } public TokenGiver(int t) { numTokens = t; }
... becomes ...
public TokenGiver() : this(0) { } public TokenGiver(int t) { numTokens = t; }
Ed S. source share