20155223 第十一周课堂编码

20155223 第十一周课堂编码

内容一

内容二

根据以下功能描述补全代码:
图中橙色方框内为需补充部分。

补全后的代码片段:

while (tokenizer.hasMoreTokens()) {
            token = tokenizer.nextToken();


            if (isOperator(token)) {
                op2 = (stack.pop()).intValue();
                op1 = (stack.pop()).intValue();
                result = evalSingleOp(token.charAt(0), op1, op2);
                stack.push(new Integer(result));
            } else {
                stack.push(new Integer(Integer.parseInt(token)));
            }

        }

补全代码后的运行截图:

posted @ 2017-05-03 16:19  陆基神盾  阅读(126)  评论(0编辑  收藏  举报