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/18 12:02] blay [Je sais passer du code au modèle] |
2017_2018:s2:td:td_classe_code [2018/02/19 10:53] blay [Je sais passer du dessin d'une association au code] |
||
---|---|---|---|
Line 11: | Line 11: | ||
</note> | </note> | ||
+ | <note tip>L'utilisation d'un outil pour coder n'est pas indispensable dans ce TD. Si vous le voulez vous pouvez utiliser ECLIPSE, mais la version NEON3, les autres ne fonctionnent pas...</note> | ||
===== Je comprends ===== | ===== Je comprends ===== | ||
Line 96: | 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 210: | 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 286: | 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]); |
} | } | ||