1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
|
import java.util.*;
interface PersonnelsStandard{
List historique();
void ajoutHistorique(Sites s);
}
public class TestPersonnelsv1 {
public static void main(String[] args) {
Personnels p1=new Personnels(101,"Dupont","Paris",2000,2);
Personnels p2=new Personnels(102,"Martin","Lyon",2500,10);
Sites siteVente1= new SiteVente("Paris");
Sites siteVente2= new SiteVente("Lyon");
Sites siteProd1= new SiteProduction("Lille");
siteVente1.ajoutPersonnel(p1);
siteVente1.ajoutPersonnel(p2);
System.out.println(p1);
System.out.println(p2);
siteVente1.transfertPersonnel(p1,siteVente2);
siteVente1.transfertPersonnel(p2,siteProd1);
System.out.println(p1);
System.out.println(p2);
}
}
class Personnels implements Comparable, PersonnelsStandard{
int no;
int anciennete;
String nom;
String adresse;
ElementsSalaire es;
HistoriqueServices histo;
Personnels(int no,String n,String a, int base,int anc){
this.no=no; à compléter
}
public String toString(){
return no + " " + nom + " " + " base "+ es.salaireBase+" Primes " + es.primes + " sal. Total "+es.salaireTotal()+
" Histo Serv. "+historique();
}
public List historique(){
return histo.services;}
public void ajoutHistorique(Sites s){histo.services.add(s);}
public void ajoutPrime(String pr){
if (pr=="PA") {es.primes.add(es.new PrimeAnciennete(this));}
if (pr=="PR") {es.primes.add(es.new PrimeResultat(this));}
}
public void suppressionPrime(String pr){
à compléter
}
public int compareTo(Object o){
return(no-((Personnels)o).no);
}
private class ElementsSalaire{
int salaireBase;
List primes;
ElementsSalaire(int b){salaireBase=b;primes= new ArrayList();}
int salaireTotal(){
int x=0;
for (int i=0;i<primes.size();i++)x=x+((Prime)(primes.get(i))).montant;
return salaireBase+x;}
class PrimeAnciennete extends Prime{
PrimeAnciennete(Personnels p){
super(p);type="PA";calculPrime();
}
void calculPrime(){
montant=(int)(p.es.salaireBase*anciennete*0.02);
}
public String toString(){return "PA= "+montant;}
}
class PrimeResultat extends Prime{ PrimeResultat(Personnels p){
super(p);type="PR";calculPrime();
}
void calculPrime(){
montant=(int) (p.es.salaireBase*0.05);
}
public String toString(){
return type+" "+montant;}
}
}
class HistoriqueServices{
List services;
HistoriqueServices(){services= new ArrayList();}
}
}
abstract class Prime implements Comparable{
Personnels p;
int montant; String type;
static List L=new ArrayList(); Prime(Personnels p){this.p=p;L.add(this);}
abstract void calculPrime();
public String toString(){return type;}
public int compareTo(Object o){return montant - ((Prime)o).montant;}
}
/*****************************************SITES************************************************/
abstract class Sites{ String localisation; String refSite;Set listePesrsonnels;}
Sites(){ à compléter }
void transfertPersonnel(Personnels p, Sites ns){
ns.ajoutPersonnel(p);
suppressionPersonnel(p);
}
void affectationPersonnel(Personnels p){
ajoutPersonnel(p);
}
void ajoutPersonnel(Personnels p){
listePesrsonnels.add(p);
p.ajoutHistorique(this);
}
void suppressionPersonnel(Personnels p){
listePesrsonnels.remove(p);
}
static Set listePersonnelsSSPrime(){
à compléter
}
}
class SiteProduction extends Sites{
int capaciteProduction;
SiteProduction(String l){localisation = l; capaciteProduction = 1000;} public String toString(){return "Site Prod. " + localisation;}
void ajoutPersonnel(Personnels p){
super.ajoutPersonnel(p);
p.ajoutPrime("PA");
}
void suppressionPersonnel(Personnels p){
super.suppressionPersonnel(p);
p.suppressionPrime("PA");
}
}
class SiteVente extends Sites{
int capacitéStock;
SiteVente(String l){localisation = l;}
public String toString(){return "Site Vente. " + localisation;} void ajoutPersonnel(Personnels p){
super.ajoutPersonnel(p);
p.ajoutPrime("PR");
}
void suppressionPersonnel(Personnels p){
super.suppressionPersonnel(p);
p.suppressionPrime("PR");
}
} |
Partager