/* Affectation entre variable agregees       */

public class AffectationVariablesAgregeesEnConsole {

/* 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) {
    Console.setTitle("AffectationVariablesAgregees");
    Position3D p1 = new Position3D();
    Position3D p2 = new Position3D();
    Console.afficherln("Variables après déclaration");
    Console.afficherln("P1 : ",p1.x," ",p1.y," ",p1.z);
    Console.afficherln("P2 : ",p2.x," ",p2.y," ",p2.z);
    Console.afficherln();
    p2.x = 1.0;
    p2.y = 1.0;
    p2.z = 1.0;
    Console.afficher("Après affectations sur ");
    Console.afficherln("les variables membres de P2");
    Console.afficherln("P1 : ",p1.x," ",p1.y," ",p1.z);
    Console.afficherln("P2 : ",p2.x," ",p2.y," ",p2.z);
    Console.afficherln();
    p1 = p2;
    Console.afficherln("Après affectation de P2 à P1");
    Console.afficherln("P1 : ",p1.x," ",p1.y," ",p1.z);
    Console.afficherln("P2 : ",p2.x," ",p2.y," ",p2.z);
    Console.afficherln();
    p1.x = 4.0;
    p2.y = 2.0;
    Console.afficher("Après affectations sur les ");
    Console.afficherln("variables membres de P1 & P2");
    Console.afficherln("P1 : ",p1.x," ",p1.y," ",p1.z);
    Console.afficherln("P2 : ",p2.x," ",p2.y," ",p2.z);
    Console.afficher("-> Il n'y a plus qu'une seule ");
    Console.afficherln("variable avec deux noms");
  }
}