Паттерн: Интерпретатор (Interpreter)
Исходник: Constant.java, язык: java [code #492, hits: 9937]
автор: this [добавлен: 05.10.2007]
  1. package interpreter;
  2.  
  3. public class Constant implements BooleanExp {
  4. private boolean constant;
  5.  
  6. public Constant(boolean constant) {
  7. super();
  8. this.constant = constant;
  9. }
  10.  
  11. public BooleanExp Copy() {
  12. return new Constant(this.constant);
  13. }
  14.  
  15. public boolean Evaluate(Context c) {
  16. return this.constant;
  17. }
  18.  
  19. public BooleanExp Replace(String str, BooleanExp exp) {
  20. return Copy();
  21. }
  22.  
  23. }
Сущность TerminalExpression

Реализация терминальной константы языка.
Тестировалось на: java 1.5.0_04

+добавить реализацию