Created
July 8, 2020 08:42
-
-
Save BMU-Verlag/090ca27dbee303bd79362f1c7b758a03 to your computer and use it in GitHub Desktop.
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
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