#107 Interpreter example JavaDoc

This commit is contained in:
Ilkka Seppala 2015-08-18 23:10:08 +03:00
parent 0d8b3c9935
commit 5831d3239d
7 changed files with 220 additions and 186 deletions

View File

@ -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. * 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 * Expressions can be evaluated using prefix, infix or postfix notations
* This sample uses postfix, where operator comes after the operands * This sample uses postfix, where operator comes after the operands
* *
* @param args command line args
*
*/ */
public static void main(String[] args) { public static void main(String[] args) {
String tokenString = "4 3 2 - 1 + *"; String tokenString = "4 3 2 - 1 + *";

View File

@ -1,5 +1,10 @@
package com.iluwatar.interpreter; package com.iluwatar.interpreter;
/**
*
* Expression
*
*/
public abstract class Expression { public abstract class Expression {
public abstract int interpret(); public abstract int interpret();

View File

@ -1,5 +1,10 @@
package com.iluwatar.interpreter; package com.iluwatar.interpreter;
/**
*
* MinusExpression
*
*/
public class MinusExpression extends Expression { public class MinusExpression extends Expression {
private Expression leftExpression; private Expression leftExpression;

View File

@ -1,5 +1,10 @@
package com.iluwatar.interpreter; package com.iluwatar.interpreter;
/**
*
* MultiplyExpression
*
*/
public class MultiplyExpression extends Expression { public class MultiplyExpression extends Expression {
private Expression leftExpression; private Expression leftExpression;

View File

@ -1,5 +1,10 @@
package com.iluwatar.interpreter; package com.iluwatar.interpreter;
/**
*
* NumberExpression
*
*/
public class NumberExpression extends Expression { public class NumberExpression extends Expression {
private int number; private int number;

View File

@ -1,5 +1,10 @@
package com.iluwatar.interpreter; package com.iluwatar.interpreter;
/**
*
* PlusExpression
*
*/
public class PlusExpression extends Expression { public class PlusExpression extends Expression {
private Expression leftExpression; private Expression leftExpression;

View File

@ -4,6 +4,11 @@ import org.junit.Test;
import com.iluwatar.interpreter.App; import com.iluwatar.interpreter.App;
/**
*
* Application test
*
*/
public class AppTest { public class AppTest {
@Test @Test