package MI2.CC2;

// Exercice 2, question 2

public class Paire2<E extends Additionnable<E>>
    implements Additionnable<Paire2<E>> {

  private E first;
  private E second;

  private Paire2() {
    this(null, null);
  }

  public Paire2(E first, E second) {
    this.first = first;
    this.second = second;
  }

  public E first() {
    return first;
  }

  public E second() {
    return second;
  }

  public void swap() {
    E tmp = first;
    first = second;
    second = tmp;
  }

  @Override
  public Paire2<E> add(Paire2<E> t) {
    Paire2<E> result = new Paire2<>();
    result.first = first.add(t.first);
    result.second = second.add(t.second);
    return result;
  }

  @Override
  public String toString() {
    return "<" + this.first + ", " + this.second + ">";
  }
}
