Source code: exptree/operators/minimum.java
1 /* Evolvo - Image Generator
2 * Copyright (C) 2000 Andrew Molloy
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
8
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17 */
18
19 /*
20 * @(#)minimum.java 0.1 08/19/2000
21 */
22 package exptree.operators;
23
24 import java.io.*;
25 import exptree.*;
26
27
28 /**
29 * Returns the minimum value from two expressionTrees.
30 *
31 * @version 1.1 08/19/2000
32 * @author Andy Molloy
33 */
34 public class minimum implements operatorInterface, Serializable
35 {
36 /** Perform the operation. */
37 public double evaluate(expressionTree params[])
38 {
39 return Math.min(params[0].evaluate(), params[1].evaluate());
40 }
41
42 /** Returns the operator's name. */
43 public String getName()
44 {
45 return "min";
46 }
47
48 /** Performs any initialization the operator requires. */
49 public void init() {}
50
51 /** Returns the number of parameters expected by the operator. */
52 public int getNumberOfParameters() { return 2; }
53 }