#107 Interpreter example JavaDoc
This commit is contained in:
parent
0d8b3c9935
commit
5831d3239d
@ -4,7 +4,7 @@ import java.util.Stack;
|
||||
|
||||
/**
|
||||
*
|
||||
* Interpreter pattern breaks sentences into expressions (Expression) that can
|
||||
* Interpreter pattern breaks sentences into expressions ({@link Expression}) that can
|
||||
* be evaluated and as a whole form the result.
|
||||
*
|
||||
*/
|
||||
@ -12,9 +12,13 @@ public class App {
|
||||
|
||||
/**
|
||||
*
|
||||
* Program entry point.
|
||||
* <p>
|
||||
* Expressions can be evaluated using prefix, infix or postfix notations
|
||||
* This sample uses postfix, where operator comes after the operands
|
||||
*
|
||||
* @param args command line args
|
||||
*
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
String tokenString = "4 3 2 - 1 + *";
|
||||
|
@ -1,5 +1,10 @@
|
||||
package com.iluwatar.interpreter;
|
||||
|
||||
/**
|
||||
*
|
||||
* Expression
|
||||
*
|
||||
*/
|
||||
public abstract class Expression {
|
||||
|
||||
public abstract int interpret();
|
||||
|
@ -1,5 +1,10 @@
|
||||
package com.iluwatar.interpreter;
|
||||
|
||||
/**
|
||||
*
|
||||
* MinusExpression
|
||||
*
|
||||
*/
|
||||
public class MinusExpression extends Expression {
|
||||
|
||||
private Expression leftExpression;
|
||||
|
@ -1,5 +1,10 @@
|
||||
package com.iluwatar.interpreter;
|
||||
|
||||
/**
|
||||
*
|
||||
* MultiplyExpression
|
||||
*
|
||||
*/
|
||||
public class MultiplyExpression extends Expression {
|
||||
|
||||
private Expression leftExpression;
|
||||
|
@ -1,5 +1,10 @@
|
||||
package com.iluwatar.interpreter;
|
||||
|
||||
/**
|
||||
*
|
||||
* NumberExpression
|
||||
*
|
||||
*/
|
||||
public class NumberExpression extends Expression {
|
||||
|
||||
private int number;
|
||||
|
@ -1,5 +1,10 @@
|
||||
package com.iluwatar.interpreter;
|
||||
|
||||
/**
|
||||
*
|
||||
* PlusExpression
|
||||
*
|
||||
*/
|
||||
public class PlusExpression extends Expression {
|
||||
|
||||
private Expression leftExpression;
|
||||
|
@ -4,6 +4,11 @@ import org.junit.Test;
|
||||
|
||||
import com.iluwatar.interpreter.App;
|
||||
|
||||
/**
|
||||
*
|
||||
* Application test
|
||||
*
|
||||
*/
|
||||
public class AppTest {
|
||||
|
||||
@Test
|
||||
|
Loading…
x
Reference in New Issue
Block a user