/* Affectation entre variable agregees       */

public class AffectationVariablesAgregees {

/* Stockage d'une position en 3 dimensions   */

  static class Position3D {
    double x = 0.0; 
    double y = 0.0; 
    double z = 0.0; };

/* Programme principal                       */

  public static void main(String [] args) {
    Position3D p1 = new Position3D();
    Position3D p2 = new Position3D();
    Ecran.afficherln("Variables après déclaration");
    Ecran.afficherln("P1 : ",p1.x," ",p1.y," ",p1.z);
    Ecran.afficherln("P2 : ",p2.x," ",p2.y," ",p2.z);
    Ecran.afficherln();
    p2.x = 1.0;
    p2.y = 1.0;
    p2.z = 1.0;
    Ecran.afficher("Après affectations sur ");
    Ecran.afficherln("les variables membres de P2");
    Ecran.afficherln("P1 : ",p1.x," ",p1.y," ",p1.z);
    Ecran.afficherln("P2 : ",p2.x," ",p2.y," ",p2.z);
    Ecran.afficherln();
    p1 = p2;
    Ecran.afficherln("Après affectation de P2 à P1");
    Ecran.afficherln("P1 : ",p1.x," ",p1.y," ",p1.z);
    Ecran.afficherln("P2 : ",p2.x," ",p2.y," ",p2.z);
    Ecran.afficherln();
    p1.x = 4.0;
    p2.y = 2.0;
    Ecran.afficher("Après affectations sur les ");
    Ecran.afficherln("variables membres de P1 & P2");
    Ecran.afficherln("P1 : ",p1.x," ",p1.y," ",p1.z);
    Ecran.afficherln("P2 : ",p2.x," ",p2.y," ",p2.z);
    Ecran.afficher("-> Il n'y a plus qu'une seule ");
    Ecran.afficherln("variable avec deux noms");
  }
}