This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
2017_2018:s2:td:td_classe_code [2018/02/19 10:45] blay [Je sais passer du dessin d'une association au code] |
2017_2018:s2:td:td_classe_code [2018/02/19 15:44] (current) blay [Je sais passer du dessin d'une classe avec un attribut et une méthode au code] |
||
---|---|---|---|
Line 23: | Line 23: | ||
** En Java** | ** En Java** | ||
<code java> | <code java> | ||
- | public class Engin { | + | public class Engine { |
} | } | ||
</code> | </code> | ||
Line 29: | Line 29: | ||
** En C#** | ** En C#** | ||
<code c#> | <code c#> | ||
- | public class Engin { | + | public class Engine { |
}; | }; | ||
</code> | </code> | ||
Line 36: | Line 36: | ||
<code php> | <code php> | ||
<?php | <?php | ||
- | public class Engin { | + | public class Engine { |
} | } | ||
?> | ?> | ||
Line 44: | Line 44: | ||
On crée une instance d'engin en java par le code suivant : | On crée une instance d'engin en java par le code suivant : | ||
<code> | <code> | ||
- | Engin defiance = new Engin(); | + | Engine defiance = new Engine(); |
</code> | </code> | ||
On crée un autre engin par : | On crée un autre engin par : | ||
<code> | <code> | ||
- | Engin xwing = new Engin(); | + | Engine xwing = new Engine(); |
</code> | </code> | ||
Line 134: | Line 134: | ||
**Code généré en java** | **Code généré en java** | ||
<code java> | <code java> | ||
- | public class Engin { | + | public class Engine { |
private int power; | private int power; | ||
Line 149: | Line 149: | ||
* @author blay | * @author blay | ||
*/ | */ | ||
- | class Engin { | + | class Engine { |
/** | /** | ||
* @AttributeType int | * @AttributeType int | ||
Line 168: | Line 168: | ||
<code java> | <code java> | ||
- | public class Engin { | + | public class Engine { |
private int power; | private int power; | ||
Line 214: | Line 214: | ||
//Association becomes an 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 289: | 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]); |
} | } | ||