Vous êtes sur la page 1sur 3

UNIVERSITE MOULAY ISMAIL

FACULTE DES SCIENCES A. U. : 2014 - 2015


Département de Mathématiques & Informatique Filières: SMI-5/MA-5
Meknès 16 Janvier 2015

Correction d’examen : Programmation Orientée Objet (Java)

Session Ordinaire Durée : 1h 30 min


Exercice 1
Le programme affiche :
A et A
A et A
A et B
B et A
B et A
B et B
4
6
Exercice 2
1. abstract class Employe{
private String nom, prenom, date;
private int age;
public Employe (String nom, String prenom, int age, String date)
{
this.nom = nom;
this.prenom = prenom;
this.age = age;
this.date = date;
}
public abstract double calculerSalaire();
public void affiche() {System.out.print(nom +" "+ prenom +" "+age+" "+date+" ");}
}
///////////////////////
2. class Technicien extends Employe {
private final static double FACTEUR_UNITE = 20.0;
private int unites;
public Technicien (String nom, String prenom, int age, String date, int unites)
{
super(nom, prenom, age, date);
this.unites = unites;
}
public double calculerSalaire() {return FACTEUR_UNITE*unites;}
public void affiche()
{
System.out.print("Le technicien :");
super.affiche();
System.out.print(calculerSalaire());
}
}
///////////////////////
3. class Magasinier extends Employe {
private final static double SALAIRE_HORAIRE = 90.0;
private int heures;

1/3
public Magasinier(String nom, String prenom, int age, String date,int heures)
{
super(nom, prenom, age, date);
this.heures = heures;
}
public double calculerSalaire() { return SALAIRE_HORAIRE*heures; }
public void affiche()
{
System.out.print("Le Magasinier :");
super.affiche();
System.out.print(calculerSalaire());
}
}
///////////////////////
4. public class Salaires {
public static void main(String[] args) {
Employe e1=new Technicien ("Ibrahimi","mourad", 37,"25 11 2014 ", 5000);
Employe e2=new Magasinier("Hachimi","Sihame",30,"12 03 2014",120);
e1.affiche();
System.out.println();
e2.affiche();
}
}
Exercice 3
import javax.swing.*;import java.awt.*;
class TestIHM{
public static void main(String[] argv){
JPanel jp, jp1, jp2, jp3, jp4, jp5;
JLabel lblNom, lblPrenom, lblCne, lblSexe, lblFiliere, lblNationalite ;
JTextField txtNom, txtPrenom, txtCne ;
JRadioButton jrBtnMasc, jrBtnFemi ;
ButtonGroup gp ;
JComboBox cboFiliere ;
Checkbox chkMarocaine, chkEtrangere ;
JButton btnSuivant ;
JFrame jfr = new JFrame("Carte d’identité") ;
jfr.setSize(400,400);
jfr.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
jp = new JPanel();
jp.setLayout(new GridLayout(5,1));
// La 1ère ligne
jp1 = new JPanel();
lblNom = new JLabel("Nom : ");
jp1.add(lblNom);
txtNom = new JTextField(6);
jp1.add(txtNom);
lblPrenom = new JLabel("Prénom : ");
jp1.add(lblPrenom);
txtPrenom = new JTextField(6);
jp1.add(txtPrenom);

2/3
lblCne = new JLabel("CNE : ");
jp1.add(lblCne);
txtCne= new JTextField(6);
jp1.add(txtCne);
jp.add(jp1);
// La 2ème ligne
jp2 = new JPanel();
lblSexe = new JLabel("Sexe: ");
jp2.add(lblSexe);
jrBtnMasc = new JRadioButton("Masculin ",true);
jp2.add(jrBtnMasc);
jrBtnFemi = new JRadioButton("Féminin");
jp2.add(jrBtnFemi);
jp.add(jp2);
gp = new ButtonGroup();
gp.add(jrBtnMasc);
gp.add(jrBtnFemi);

// La 3ème ligne
jp3 = new JPanel();
lblFiliere = new JLabel("Filière :");
jp3.add(lblFiliere);
cboFiliere = new JComboBox();
cboFiliere.addItem("SMI");
cboFiliere.addItem("SMPC");
cboFiliere.addItem("SVTU");
jp3.add(cboFiliere);
jp.add(jp3);

// La 4ème ligne
jp4 = new JPanel();
lblNationalite = new JLabel("Nationalité: ");
chkMarocaine = new Checkbox("Marocaine", true);
chkEtrangere = new Checkbox("Etrangère");
jp4.add(lblNationalite);
jp4.add(chkMarocaine);
jp4.add(chkEtrangere);
jp.add(jp4);

// La 5ème ligne
jp5 = new JPanel();
btnSuivant = new JButton("Suivant");
jp5.add(btnSuivant);
jp.add(jp5);

jfr.add(jp);
jfr.show();

}
}

3/3

Vous aimerez peut-être aussi