package uk.ac.cam.rkh23.OOP.Complex;

/**
 * A mutable complex number that is parameterised to take
 * different underlying representations e.g. integers, floats, doubles. 
 * T is a placeholder - when we create ParameterisedComplex<XXX> we effectively
 * search and replace "T" with "XXX".
 * @author robert
 *
 * @param <T> 
 */
public class ParameterisedComplex<T> {

	// Two pieces of state with the type T
	private  T mImag;
	private  T mReal;

	/**
	 * Setter method
	 * @param real
	 * @param imag
	 */
	public void set(T real, T imag) {
		mReal=real;
		mImag=imag;
	}
	
	public T getImag() {
		return mImag;
	}
	
	public T getReal() {
		return mReal;
	}
	
	
	// Note we can't do an add function because T could be any type and
	// using "+" only works on primitives...
	
	public static void main(String[] args) {
		// Create one based on doubles
		ParameterisedComplex<Double> a = new ParameterisedComplex<Double>();
		a.set(1.0, 1.0);
		// on integers
		ParameterisedComplex<Integer> b = new ParameterisedComplex<Integer>();
		b.set(2,2);
		// on arrays (makes no conceptual sense!)
		ParameterisedComplex<int[]> c = new ParameterisedComplex<>();
		c.set(new int[]{2},new int[]{3});
		
	}
}
