testexprreader.java

来自「国外的数据结构与算法分析用书」· Java 代码 · 共 29 行

JAVA
29
字号
import java.io.*;
import dslib.dictionary.arrayed.ArrayedPKeyedDictUos;

/**	This class tests the classes of Chapter 9. */
public class TestExprReader
{ 
	public static void main(String args[]) throws Exception 
	{
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
		ExprScanner scanner = new ExprScanner(input);	
		ExprParser exprParser = new ExprParser(scanner);
		System.out.println("\nFor the purpose of this program, an expression involves the operations\n "
						+"+, -, *, / with optional () and white space, and a required terminating ; \n");
		System.out.print("Do you wish to enter another expression (n or y)?");
		char charRead = (char) input.read();
		while (charRead == 'y')
		{
			input.readLine();
			System.out.print("Please enter an expression: ");
			scanner.initialize();
			ExprTree tree = exprParser.expr();
			System.out.println("Expression is : "+tree);
			input.readLine();
			System.out.print("Do you wish to enter another expression (n or y)?");
			charRead = (char) input.read();		
		}	
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?