《Java与模式》这本书的源代码

源代码在线查看: and.java

软件大小: 317 K
上传用户: reed2453
关键词: Java 模式 源代码
下载地址: 免注册下载 普通下载 VIP

相关代码

				package com.javapatterns.interpreter;
				
				public class And extends Expression
				{
				    /**
				     * @link aggregation 
				     */
				    private Expression left, right;
				
				    public And(Expression left, Expression right)
				    {
						this.left = left;
						this.right = right;
				    }
				
				    public boolean interpret(Context ctx)
				    {
				        return left.interpret(ctx) && right.interpret(ctx);
				    }
				
				    public boolean equals(Object o)
				    {
				        if (o != null && o instanceof And)
				        {
				          return this.left.equals(((And) o).left) &&
				                 this.right.equals(((And) o).right);
				        }
				        return false;
				    }
				
				    public int hashCode()
				    {
				        return (this.toString()).hashCode();
				    }
				
				    public String toString()
				    {
						return "(" + left.toString() + " AND " + right.toString() + ")";
				    }
				}
							

相关资源