View Javadoc

1   /*
2    * Created on Aug 31, 2004 
3    * Original filename was BinaryOperation.java
4    * 
5    *   Magic-Project is a turn based strategy simulator
6    *   Copyright (C) 2003-2007 Fabrice Daugan
7    *
8    *   This program is free software; you can redistribute it and/or modify it 
9    * under the terms of the GNU General Public License as published by the Free 
10   * Software Foundation; either version 2 of the License, or (at your option) any
11   * later version.
12   *
13   *   This program is distributed in the hope that it will be useful, but WITHOUT 
14   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15   * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more 
16   * details.
17   *
18   *   You should have received a copy of the GNU General Public License along  
19   * with this program; if not, write to the Free Software Foundation, Inc., 
20   * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21   * 
22   */
23  package net.sf.magicproject.operation;
24  
25  import java.io.IOException;
26  import java.io.InputStream;
27  
28  import net.sf.magicproject.expression.BinaryExpression;
29  import net.sf.magicproject.expression.Expression;
30  import net.sf.magicproject.expression.ExpressionFactory;
31  
32  
33  /***
34   * Represents a binary operation.
35   * 
36   * @author <a href="mailto:fabdouglas@users.sourceforge.net">Fabrice Daugan </a>
37   */
38  public abstract class BinaryOperation extends Operation {
39  
40  	/***
41  	 * Creates a new instance of BinaryOperation <br>
42  	 */
43  	protected BinaryOperation() {
44  		super();
45  	}
46  
47  	@Override
48  	public Expression readNextExpression(InputStream inputFile)
49  			throws IOException {
50  		return new BinaryExpression(this, ExpressionFactory
51  				.readNextExpression(inputFile), ExpressionFactory
52  				.readNextExpression(inputFile));
53  	}
54  
55  	@Override
56  	public abstract int process(int leftValue, int rightValue);
57  
58  	@Override
59  	public abstract String getOperator();
60  
61  }