aboutsummaryrefslogtreecommitdiffstats
path: root/src/jcgp/backend/population/Input.java
blob: 97fe82b9f000c7a54e2a7e24ffd8b0e10082451d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package jcgp.backend.population;

/**
 * This is a chromosome input. Inputs are a special
 * type of connection which simply return a set value.
 * They do not have connections and instead provide a
 * starting point for the chromosome's active paths.
 * 
 * @author Eduardo Pedroni
 *
 */
public class Input implements Connection {
	
	private Object value;
	private int index;
	
	/**
	 * Initialises a new input with the current index.
	 * 
	 * @param index the index of the new input.
	 */
	public Input(int index) {
		this.index = index;
	}
	
	/**
	 * Sets this input's value. The new value
	 * will now be returned by this input's
	 * {@code getValue()} method.
	 * 
	 * @param newValue the value to set.
	 */
	public void setValue(Object newValue) {
		value = newValue;
	}

	/**
	 * @return the input's index.
	 */
	public int getIndex() {
		return index;
	}
	
	@Override
	public Object getValue() {
		return value;
	}

	@Override
	public String toString() {
		return "Input " + index;
	}
}