Académique Documents
Professionnel Documents
Culture Documents
LACHGAR | Java | Chapitre: Classes et Objets | 26693 visites | Facile | Corrigé
Outils de développement
Utilitaires
Outils en ligne
Structure de projet
1. package ma.exelib.projet.ecole;
2.
3. public class Specialite {
4. private int id;
5. private String code;
6. private String libelle;
7. private static int count;
8.
9. public Specialite(String code, String libelle) {
10. this.id = ++count;
11.
12. this.code = code;
13. this.libelle = libelle;
14. }
15.
16. public int getId() {
17. return id;
18. }
19.
20. public void setId(int id) {
21. this.id = id;
22. }
23.
24. public String getCode() {
25. return code;
26. }
27.
28. public void setCode(String code) {
29. this.code = code;
30. }
31.
32. public String getLibelle() {
33. return libelle;
34. }
35.
36. public void setLibelle(String libelle) {
37. this.libelle = libelle;
38. }
39.
40. public static int getCount() {
41. return count;
42. }
43.
44. public static void setCount(int count) {
45. Specialite.count = count;
46. }
47.
48. public String toString() {
49. return "Spécialité "+ this.libelle;
50. }
51.
52. }
1. package ma.exelib.projet.ecole;
2.
3. public class Professeur {
4. private int id;
5. private String nom;
6. private String prenom;
7. private String telephone;
8. private String email;
9. private Specialite specialite;
10. private static int count;
11.
12. public Professeur(String nom, String prenom, String telephone,
13. String email, Specialite specialite) {
14. this.id = ++count;
15. this.nom = nom;
16. this.prenom = prenom;
17. this.telephone = telephone;
18. this.email = email;
19. this.specialite = specialite;
20. }
21.
22. public int getId() {
23. return id;
24. }
25.
26. public void setId(int id) {
27. this.id = ++count;
28. }
29.
30. public String getNom() {
31. return nom;
32. }
33.
34. public void setNom(String nom) {
35. this.nom = nom;
36. }
37.
38. public String getPrenom() {
39. return prenom;
40. }
41.
42. public void setPrenom(String prenom) {
43. this.prenom = prenom;
44. }
45.
46. public String getTelephone() {
47. return telephone;
48. }
49.
50. public void setTelephone(String telephone) {
51. this.telephone = telephone;
52. }
53.
54. public String getEmail() {
55. return email;
56. }
57.
58. public void setEmail(String email) {
59. this.email = email;
60. }
61.
62. public Specialite getSpecialite() {
63. return specialite;
64. }
65.
66. public void setSpecialite(Specialite specialite) {
67. this.specialite = specialite;
68. }
69.
70. public String toString() {
71. return "-" + this.nom.toUpperCase() + " "
72. + this.prenom.substring(0, 1).toUpperCase() + ""
73. + this.prenom.substring(1).toLowerCase() + " " + this.email;
74. }
75.
76. }
package ma.exelib.projet.ecole.test;
import ma.exelib.projet.ecole.Professeur;
import ma.exelib.projet.ecole.Specialite;
Ajoutez aux favoris : Cliquez pour ajouter cet article à vos favoris
Share
Sauvegarde et lecture d'un tableau d'étudiants dans un chier texte Gestion de location des voitures en C
Langage C Langage C
Le contenu de ce site est fourni dans un but d'apprentissage et de partage d'information et ne peut en aucun cas remplacer le travail effectué en classe.