Skip to content

Instantly share code, notes, and snippets.

@BMU-Verlag
Created July 8, 2020 08:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BMU-Verlag/090ca27dbee303bd79362f1c7b758a03 to your computer and use it in GitHub Desktop.
Save BMU-Verlag/090ca27dbee303bd79362f1c7b758a03 to your computer and use it in GitHub Desktop.
enum Gehaltskategorien {
A(18000, true),
B(20400, true),
C(24000, false),
D(30000, true),
E(42000, false),
F(60000, false);
private int gehalt;
private boolean bonus;
Gehaltskategorien(final int gehalt, final boolean bonus){
this.gehalt = gehalt;
this.bonus = bonus;
}
public int getGehalt(){
return this.gehalt;
}
public boolean getBonus(){
return this.bonus;
}
}
public class Enum {
public static void main(String[] args) {
Gehaltskategorien mitarbeiter = Gehaltskategorien.C;
System.out.println("Das Jahresgehalt des Mitarbeiters beträgt " + mitarbeiter.getGehalt() + " Euro.");
if (mitarbeiter.getBonus()){
System.out.println("Der Mitarbeiter erhält einen Bonus von 2000 Euro.");
}
else {
System.out.println("Der Mitarbeiter erhält keinen Bonus.");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment