version 222222
Mon Dec 09 2024 14:04:17 GMT+0000 (Coordinated Universal Time)
Saved by @saharmess #mysql
class employe{ private String nom; private String pre; private int age; private float salaire; employe(){ this.nom="sis"; this.pre="kakak"; this.age=58; this.salaire=7892; } employe(String nom,String pre,int age,float salaire){ this.nom=nom; this.pre=pre; this.age=age; this.salaire=salaire; } employe (employe e){ this.nom=e.nom; this.pre=e.pre; this.age=e.age; this.salaire=e.salaire; } String getNom(){ return this.nom; } String getPre(){ return this.pre; } int getAge(){ return this.age; } float getSalaire(){ return this.salaire; } void setNom(String nom){ this.nom=nom; } void setPre(String pre){ this.pre=pre; } void setAge(int age){ this.age=age; }void setSalaire(float salaire){ this.salaire=salaire; } void aug(float sa){ this.salaire+=sa; } public String toString(){ String ch; ch="Employe[Nom:"+this.nom+"| Prenom:"+this.pre+"| Age:"+this.age+"| Salaire:"+this.salaire; return ch; } void affiche(){ System.out.println(this.toString()); }} class tech extends employe{ private int grade; public tech() { super(); // Appelle le constructeur par défaut de employe this.grade = 1; // Valeur par défaut pour grade } tech(String nom,String pre,int age,float salaire,int grade){ super(nom,pre,age,salaire); setGrade(grade); } int getGrade(){ return this.grade; } void setGrade(int grade){ if(grade>=1 && grade<=3){ this.grade=grade; }else{ System.out.println("grade invalid"); }} int prime(){ switch(grade){ case 1:return 100; case 2:return 200; case 3:return 300; default:return 0; } } public String toString(){ String ch; ch=super.toString()+"| le grade :"+this.grade+"|le prime :"+this.prime(); return ch; } void augg(){ this.aug(this.prime()); } } class equipe extends tech{ private tech [] tab; equipe(tech[] tab){ this.tab=tab; } public tech hisa(){ tech higs=tab[0]; for(int i=0;i<tab.length;i++){ if(tab[i].getSalaire()>higs.getSalaire()){ higs=tab[i]; } } return higs; } public tech higa(){ tech hig=tab[0]; for(int i=0;i<tab.length;i++){ if(tab[i].getGrade()>hig.getGrade()){ hig=tab[i]; } } return hig; } } public class Main{ public static void main(String [] args){ employe e1=new employe("sahar","mess",20,9000); tech t1=new tech("ahmed","ben",25,10000,1); e1.affiche(); t1.affiche(); e1.aug(500); e1.affiche(); t1.setGrade(2); t1.augg(); t1.affiche(); tech t2=new tech("amir","jerbi",30,1852,2); tech t3=new tech("sara","ouraj",21,47859,1); tech t4=new tech("farah","chao",29,47899,3); tech t5=new tech("alona","zyan",45,8000,2); tech[] tab={t2,t3,t4,t5}; equipe eq=new equipe(tab); System.out.println("Highest Salary Technician: " + eq.hisa()); System.out.println("Highest Grade Technician: " + eq.higa()); } }
Comments