Devoir java2 TD TP - Classes Abstraites et Interfaces Partie Classes Abstraites Exercice package abstractpersonne public abstract class personne protected String nom protected String prenom protected String rue protected String ville protected static int

TD TP - Classes Abstraites et Interfaces Partie Classes Abstraites Exercice package abstractpersonne public abstract class personne protected String nom protected String prenom protected String rue protected String ville protected static int nbPersonnes public personne String nom String prenom String rue String ville this nom nom this prenom prenom this rue rue this ville ville nbPersonnes public String toString return nom prenom rue ville public void modi ?erPersonne String rue String ville this rue rue this ville ville ecrirePersonne static void nbPersonne System out println n Nombre d ? employés nbPersonnes n Nombre de secrétaires secretaire nbSecretaires n Nombred ? enseignants Enseignant nbEnseignants n Nombre d ? étudiants Etudiant nbEtudiants abstract void ecrirePersonne public static void main String args Csecretaire soc new secretaire Sara sou ? Rue de melahi rabat gt soc ecrirePersonne Enseignant en new Enseignant Ahmed Sbihi Rue de al farah tetouan ere annee renouvlable en ecrirePersonne Etudiant et new Etudiant ahmed koko Rue asilal tanger eme annee genie civil et ecrirePersonne System out println n l'a ?chage apres la modi ?cation soc modi ?erPersonne Rue de checha fes en modi ?erPersonne Rue de a ?lal casablanca personne nbPersonne ackage abstractpersonne public class secretaire extends personne private String numeroBureau private static int nbSecretaires secretaire String nom String prenom String rue String ville String numeroBureau super nom prenom rue ville this numeroBureau numeroBureau nbSecretaires public String toString return super toString n Numero de bureau numeroBureau void ecrirePersonne System out println Secrétaire toString static int nbSecretaires return nbSecretaires package abstractpersonne Cpublic class Etudiant extends personne String diplomeEnCours static int nbEtudiants public Etudiant String nom String prenom String rue String ville String diplomeEnCours super nom prenom rue ville this diplomeEnCours diplomeEnCours nbEtudiants public String toString return super toString le diplome diplomeEnCours void ecrirePersonne System out println Etudiant toString static int nbEtudiants return nbEtudiants package abstractpersonne public class Enseignant extends personne private String specialite private static int nbEnseignants public Enseignant String nom String prenom String rue String ville String specialite super nom prenom rue ville this specialite specialite nbEnseignants public String toString return super toString n spécialité specialite void ecrirePersonne CSystem out println Enseignant toString static int nbEnseignants return nbEnseignants Exercice abstract class ObjetGraphique protected int x y void ObjetGraphique x y abstract void a ?che public ObjetGraphique int x int y this x x this y y public ObjetGraphique ObjetGraphique Obj x Obj x y Obj y public int getX return x Cpublic int getY return y public void setPosition int x int y this x x this y y public void deplacer int dx int dy this x x dx this y y dy public abstract class Rectangle extends ObjetGraphique double largeur hauteur public void Rectangle largeur hauteur public Rectangle int x int y double largeur double hauteur super x y this largeur largeur this hauteur hauteur public void Rectangle Rectangle Rec x Rec x y Rec y largeur Rec largeur hauteur Rec hauteur public double getHauteur return hauteur hauteur public double getLargeur return largeur public void setObjetGraphique int x

  • 23
  • 0
  • 0
Afficher les détails des licences
Licence et utilisation
Gratuit pour un usage personnel Aucune attribution requise
Partager