This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
2017_2018:s2:td:td_classe_code [2018/02/19 10:26] blay [Des modèles aux codes et vis-versa] |
2017_2018:s2:td:td_classe_code [2018/02/19 10:53] blay [Je sais passer du dessin d'une association au code] |
||
---|---|---|---|
Line 97: | Line 97: | ||
private int power; | private int power; | ||
+ | //Accesseur en lecture : on lit la valeur de l'attribut power | ||
public int getPower() { | public int getPower() { | ||
return power; | return power; | ||
} | } | ||
+ | |||
+ | //Accesseur en écriture : on modifie la valeur de l'attribut power (noté this.power) avec la valeur en parametre power | ||
public void setPower(int power) { | public void setPower(int power) { | ||
this.power = power; | this.power = power; | ||
Line 211: | Line 213: | ||
private int power; | private int power; | ||
- | //Association becomes un attribute ; multiplicity * => array or any collections | + | //Association becomes an attribute ; multiplicity * => array or any collections |
- | private Pilot[] pilots = new Pilot[0]; | + | private Pilot[] pilots; // = new Pilot[0]; //array de dimension 1 |
Line 287: | Line 289: | ||
//Get the pilots of defiance | //Get the pilots of defiance | ||
- | Pilot[] pilots = defiance.getPilots(); | + | Pilot[] ourPilots = defiance.getPilots(); |
//Print the first pilot (only object reference) | //Print the first pilot (only object reference) | ||
- | System.out.println("Pilot : " + pilots[0]); | + | System.out.println("Pilot : " + ourPilots[0]); |
} | } | ||