Vorlesung 8 / Aufgabe 4

This commit is contained in:
Sebastian Brosch 2024-05-16 16:32:58 +02:00
parent 203e18ca10
commit ee2b5d5e1c
6 changed files with 106 additions and 0 deletions

View File

@ -0,0 +1,30 @@
package VL08.Aufgabe04;
import VL08.Aufgabe04.PersonenDH.Person;
import VL08.Aufgabe04.PersonenDH.Student;
import VL08.Aufgabe04.PersonenDH.Studiengangsleiter;
import VL08.Aufgabe04.PersonenDH.Dozent;
import VL08.Aufgabe04.PersonenDH.Mitarbeiter;
import java.util.ArrayList;
/**
* Vorlesung 8 / Aufgabe 4
*
* @author Sebastian Brosch
*/
public class Aufgabe04 {
public static void main(String[] args) {
ArrayList<Person> personen = new ArrayList<Person>();
personen.add(new Person("Petra Mustermann", 37));
personen.add(new Student("Max Mustermann", 30, "1234567"));
personen.add(new Dozent("Eva Mustermann", 50, "Informatik"));
personen.add(new Mitarbeiter("Tim Mustermann", 35, "Programmieren"));
personen.add(new Studiengangsleiter("Kevin Mustermann", 40, "BWL", "BWL 1"));
for (Person person : personen) {
person.print();
System.out.println("-------------------------");
}
}
}

View File

@ -0,0 +1,15 @@
package VL08.Aufgabe04.PersonenDH;
public class Dozent extends Person {
private String specialization;
public Dozent(String name, int age, String specialization) {
super(name, age);
this.specialization = specialization;
}
public void print() {
super.print();
System.out.printf("Fachrichtung: %s\n", specialization);
}
}

View File

@ -0,0 +1,15 @@
package VL08.Aufgabe04.PersonenDH;
public class Mitarbeiter extends Person {
private String activity;
public Mitarbeiter(String name, int age, String activity) {
super(name, age);
this.activity = activity;
}
public void print() {
super.print();
System.out.printf("Tätigkeit: %s\n", this.activity);
}
}

View File

@ -0,0 +1,16 @@
package VL08.Aufgabe04.PersonenDH;
public class Person {
String name;
int age;
public Person(String name, int age) {
this.name = name;
this.age = age;
}
public void print() {
System.out.printf("Name: %s\n", this.name);
System.out.printf("Alter: %d\n", this.age);
}
}

View File

@ -0,0 +1,15 @@
package VL08.Aufgabe04.PersonenDH;
public class Student extends Person {
private String studentNumber;
public Student(String name, int age, String studentNumber) {
super(name, age);
this.studentNumber = studentNumber;
}
public void print() {
super.print();
System.out.printf("Matrikel-Nummer: %s\n", this.studentNumber);
}
}

View File

@ -0,0 +1,15 @@
package VL08.Aufgabe04.PersonenDH;
final public class Studiengangsleiter extends Dozent {
private String course;
public Studiengangsleiter(String name, int age, String specialization, String course) {
super(name, age, specialization);
this.course = course;
}
public void print() {
super.print();
System.out.printf("Kurs: %s\n", this.course);
}
}