Complexe2.java

public class Complexe2 extends Complexe {
  public Complexe2(double r, double i) {
    super(r,i);
  }
  public boolean equals(Object obj) {
    if (!(obj instanceof Complexe2))
      return false;
    Complexe2 c = (Complexe2)obj;
    return (partieRéelle == c.partieRéelle &&
        partieImaginaire == c.partieImaginaire);
  }
  public static void main(String[] args) {
    Complexe2 c1 = new Complexe2(1.0,2.0);
    Complexe2 c2 = new Complexe2(1.0,2.0);
    Complexe2 c3 = new Complexe2(2.0,3.0);
    String s  = new String("Bonjour");
    System.out.println(c1.equals(c1)); // affiche true
    System.out.println(c1.equals(c2)); // affiche true
    System.out.println(c2.equals(c3)); // affiche false
    System.out.println(c2.equals(s));  // affiche false
  }
}