Add constructors
This commit is contained in:
parent
40c41300ac
commit
c17fd51e08
@ -2,7 +2,12 @@ class Angestellter extends Mitarbeiter {
|
||||
|
||||
double monatsGehalt;
|
||||
|
||||
void print(){
|
||||
public Angestellter(int personalNummer, String name, String vorname, double monatsGehalt) {
|
||||
super(personalNummer, name, vorname);
|
||||
this.monatsGehalt = monatsGehalt;
|
||||
}
|
||||
|
||||
void print(){
|
||||
System.out.println(getPersonalNummer());
|
||||
System.out.println(getName());
|
||||
System.out.println(getVorname());
|
||||
|
@ -1,6 +1,6 @@
|
||||
class Aufgabe {
|
||||
public static void main(String[] args) {
|
||||
Manager person = new Manager();
|
||||
Manager person = new Manager(1, "Wurst", "Hans", 100, 1000);
|
||||
person.print();
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,9 @@
|
||||
public class LeitenderAngestellter extends Angestellter {
|
||||
double bonus;
|
||||
|
||||
LeitenderAngestellter(double bonus) {
|
||||
super();
|
||||
public LeitenderAngestellter(int personalNummer, String name, String vorname, double monatsGehalt, double bonus) {
|
||||
super(personalNummer, name, vorname, monatsGehalt);
|
||||
this.bonus = bonus;
|
||||
}
|
||||
|
||||
void print() {
|
||||
|
@ -1,6 +1,10 @@
|
||||
class Manager extends LeitenderAngestellter {
|
||||
Dienstwagen dienstwagen;
|
||||
|
||||
public Manager(int personalNummer, String name, String vorname, double gehalt, double bonus){
|
||||
super(personalNummer, name, vorname, gehalt, bonus);
|
||||
}
|
||||
|
||||
void print() {
|
||||
super.print();
|
||||
|
||||
|
@ -3,6 +3,12 @@ abstract class Mitarbeiter{
|
||||
String name;
|
||||
String vorname;
|
||||
|
||||
public Mitarbeiter(int personalNummer, String name, String vorname) {
|
||||
this.personalNummer = personalNummer;
|
||||
this.name = name;
|
||||
this.vorname = vorname;
|
||||
}
|
||||
|
||||
abstract void print();
|
||||
void setPersonalNummer(int i){personalNummer=i;}
|
||||
void setName(String s){name=s;}
|
||||
|
Loading…
Reference in New Issue
Block a user