Skip to content

Instantly share code, notes, and snippets.

@jewom
Created November 14, 2017 13:35
Show Gist options
  • Save jewom/7b2f60412f072f1846a60f910e2b25c7 to your computer and use it in GitHub Desktop.
Save jewom/7b2f60412f072f1846a60f910e2b25c7 to your computer and use it in GitHub Desktop.
Heritages en Java
class Employe {
private String nom;
private int salaire;
Employe(String nom, int salaire) {
this.nom = nom;
this.salaire = salaire;
}
public String getNom() {
return nom;
}
public void setNom(String nom) {
this.nom = nom;
}
public int getSalaire() {
return salaire;
}
public void setSalaire(int salaire) {
this.salaire = salaire;
}
}
public class Main {
public static void main(String[] args) {
Patron jaques_hubert = new Patron("Jacques-Hubert", 7000, 5000);
System.out.print(jaques_hubert.getSalaire());
}
}
class Patron extends Employe {
int prime;
Patron(String nom, int salaire, int prime) {
super(nom, (salaire + prime));
}
public int getPrime() {
return prime;
}
public void setPrime(int prime) {
this.prime = prime;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment