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