/**
*
* This class provides the behaviour of a Pair (2-tuple) of data values
* The 2 data are chosen from a simple enumeration of 3 values - EL1, EL2, EL3
* These values must never be the same
* @author J Paul Gibson
* @version 1
*/
public class PairOfData {
/**
* The Data values for the Pair elements
* @author gibson
*
*/
enum Data {EL1, EL2, EL3};
/**
* The first element of the Pair of Data
*/
private Data first;
/**
* The second element of the Pair of Data
*/
private Data second;
/**
*
* @param d1 First data element
* @param d2 Second data element
*/
PairOfData (Data d1, Data d2){
if (d1!= d2) {first = d1; second = d2;}
}
/**
*
* @return First data element
*/
public Data get_first(){return first;}
/**
*
* @param new_first New value for First data element
*/
public void set_first (Data new_first){first = new_first;}
/**
*
* @return Second data element
*/
public Data get_second(){return second;}
/**
*
* @param new_first New value for First data element
*/
public void set_second (Data new_first){second = new_first;}
/**
* Generate string representation as (first, second)
*/
public String toString(){ return "("+ first+", "+second+")";}
/**
* Simple self-test - for students - with results output to screen
* @param args expected to be empty
*/
public static void main (String args []){
PairOfData p = new PairOfData(Data.EL1, Data.EL1);
System.out.println("Created the pair "+ p);
}
}// ENDCLASS PairOfData