Created
January 3, 2021 19:17
-
-
Save cloudz/418415af82e4b2af237d1509c8b3b06e to your computer and use it in GitHub Desktop.
Oef 6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Oefening1; | |
public class Manager extends Werknemer { | |
private double bonus; | |
private static int aantalManagers = 0; | |
public Manager(String voornaam, String naam, String functie, double salaris, double bonus) { | |
super(voornaam, naam, functie, salaris); | |
setBonus(bonus); | |
aantalManagers++; | |
} | |
public Manager(String voornaam, String naam, String functie, double salaris) { | |
super(voornaam, naam, functie, salaris); | |
setBonus(50); | |
aantalManagers++; | |
} | |
public void setBonus(double bonus) { | |
this.bonus = bonus; | |
} | |
public double getBonus() { return this.bonus; } | |
public double getProcManagers(){ | |
return ( 100 / super.getAantalWerknemers() ) * aantalManagers; | |
} | |
@Override | |
public double getSalaris() { | |
return super.getSalaris() + getBonus(); | |
} | |
@Override | |
public void print() { | |
super.print(); | |
System.out.println("Het percentage managers tov. werknemers is " + getProcManagers() + "%"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Oefening1; | |
public class Persoon { | |
private String naam; | |
private String voornaam; | |
//CONSTRUCTOR | |
public Persoon(String naam, String voornaam) { | |
this.naam = naam; | |
this.voornaam = voornaam; | |
} | |
public Persoon(){} | |
public String getNaam() { | |
return naam; | |
} | |
public void setNaam(String naam) { | |
this.naam = naam; | |
} | |
public String getVoornaam() { | |
return voornaam; | |
} | |
public void setVoornaam(String voornaam) { | |
this.voornaam = voornaam; | |
} | |
//opdracht 4 | |
public void print(){ | |
System.out.println("Employee ID : " + getVoornaam() + " " + getNaam()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Oefening1; | |
import java.util.Locale; | |
public class Werknemer extends Persoon{ | |
private double salaris; | |
private String functie; | |
private double min_salaris = 1000; | |
private static int aantalWerknemers = 0; | |
public Werknemer(String voornaam, String naam, String functie, double salaris){ | |
super(voornaam,naam); | |
setSalaris(salaris); | |
setFunctie(functie); | |
controleSalaris(); | |
aantalWerknemers++; | |
} | |
public Werknemer(String voornaam,String naam){ | |
super(voornaam,naam); | |
this.salaris = getMinimumSalaris(); | |
this.functie = "Algemeen bediende"; | |
aantalWerknemers++; | |
} | |
//SETTERS | |
public void setFunctie(String functie) { | |
this.functie = functie; | |
} | |
public void setSalaris(double salaris) { | |
this.salaris = salaris; | |
} | |
//GETTERS | |
public String getFunctie() { | |
return functie; | |
} | |
public double getSalaris() { return this.salaris; } | |
public int getAantalWerknemers() { | |
return aantalWerknemers; | |
} | |
//METHODE | |
public double getMinimumSalaris(){ | |
return min_salaris; | |
} | |
//CONTROLE | |
public void controleSalaris(){ if (this.salaris < min_salaris) { this.salaris = min_salaris; } } | |
@Override | |
public void print() { | |
super.print(); | |
System.out.println("heeft als functie "+ getFunctie().toLowerCase(Locale.ROOT) +" met als salaris: "+ getSalaris()); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Oefening1; | |
import java.lang.ref.WeakReference; | |
public class WerknemerApp { | |
public static void main(String[] args) { | |
Werknemer werknemer1 = new Werknemer("Niels","de ridder"); | |
Werknemer werknemer2 = new Werknemer("Hans","Giets","Verkoper",1200); | |
Werknemer werknemer3 = new Werknemer("Hans","Brommer","Hersteller",950); | |
Werknemer werknemer4 = new Werknemer("Hans","Trontinet","Verkoper",600); | |
Werknemer werknemer5 = new Werknemer("Hans","Camino","Dramaqueen",950); | |
Manager manager1 = new Manager("Sander","Rutten","Baas",200000,1500); | |
Manager manager2 = new Manager("Kristof","Rutten","Super baas", 1000000); | |
werknemer1.print(); | |
werknemer2.print(); | |
werknemer3.print(); | |
werknemer4.print(); | |
werknemer5.print(); | |
manager1.print(); | |
manager2.print(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment