上QQ阅读APP看书,第一时间看更新
Use case
We will demonstrate the interpreter design pattern by using a simple number-to-character scenario. Our Code Interpreter program will accept numeric input and translate it to a series of characters. For example, an input string of 319 might return a value of YES. We will use an expression interface and three classes to demonstrate this relatively simple use case.
The following screenshot shows the example program's output, given the user's input:
Code Interpreter output
The preceding screenshot shows the user input as 319.