Skip to content
Snippets Groups Projects
Commit cf1609f3 authored by Paul Rauser's avatar Paul Rauser
Browse files

chore: add Readme as task description

parent ac77d22b
No related branches found
No related tags found
No related merge requests found
package io.fp.campus;
public class App {
public static void main(String[] args) {
Faculty hogwarts = new Faculty("Hogwarts");
Professor dumbledore = new Professor("Dumbledore", 77, "BPM", hogwarts);
System.out.println(dumbledore.getName());
System.out.println("Hält er Vorlesung? "+dumbledore.isTalking());
dumbledore.setTalking(false);
System.out.println("Hält er Vorlesung? "+dumbledore.isTalking());
Assistent hagrid = new Assistent("Hagrid", 26, hogwarts);
hagrid.setBoss(dumbledore);
System.out.println(hagrid.getName());
System.out.println(hagrid.getBoss().getName());
Assistent dobby = new Assistent("Dobby", 130, hogwarts);
dobby.setBoss(dumbledore);
Assistent pince = new Assistent("Madam Pince", 50, hogwarts);
hogwarts.addProfessor(dumbledore);
hogwarts.addAssistent(hagrid);
hogwarts.addAssistent(dobby);
hogwarts.addAssistent(pince);
System.out.println("Fakultät "+ hogwarts.getName());
System.out.println(hogwarts.getProfs().toString());
System.out.println(hogwarts.getAssis().toString());
System.out.println(hogwarts.getAssisOfProf(dumbledore));
System.out.println(hogwarts.getProfsWithAssis());
System.out.println("Anzahl Profs: " + hogwarts.getAmountProfs());
System.out.println("Anzahl Assis: " + hogwarts.getAmountAssis());
}
}
package io.fp.campus;
/**
* Assistent
*/
public class Assistent {
private String name;
private int age;
private Professor boss;
private Faculty faculty;
public Assistent(String name, int age, Faculty faculty) {
this.name=name;
this.age=age;
this.faculty = faculty;
}
public void setBoss(Professor boss) {
this.boss=boss;
}
public Professor getBoss() {
return boss;
}
public String getName() {
return name;
}
public int getAge() {
return age;
}
public String toString() {
return name;
}
public void setFaculty(Faculty faculty) {
this.faculty = faculty;
}
public Faculty getFaculty() {
return this.faculty;
}
}
\ No newline at end of file
package io.fp.campus;
import java.util.ArrayList;
/**
* Faculty
*/
public class Faculty {
private String name;
private ArrayList<Professor> profs;
private ArrayList<Assistent> assis;
public Faculty(String name) {
this.name=name;
this.assis=new ArrayList<Assistent>();
this.profs=new ArrayList<Professor>();
}
public String getName() {
return name;
}
public void addProfessor(Professor professor) {
if (!profs.contains(professor)) {
profs.add(professor);
}
else {
throw new RuntimeException();
}
}
public void addAssistent(Assistent assistent) {
if (!assis.contains(assistent))
assis.add(assistent);
}
public ArrayList<Professor> getProfs() {
return profs;
}
public ArrayList<Assistent> getAssis() {
return assis;
}
public ArrayList<Assistent> getAssisOfProf(Professor professor) {
ArrayList<Assistent> profassis = new ArrayList<>();
if (!profs.contains(professor)){
return profassis;
}
for (Assistent assi : assis) {
Professor p = assi.getBoss();
if (p!=null&&p.equals(professor)) {
profassis.add(assi);
}
}
return profassis;
}
public ArrayList<Professor> getProfsWithAssis(){
ArrayList<Professor> profsWithAssis = new ArrayList<>();
for(Assistent assi : assis){
Professor p = assi.getBoss();
if(p != null && !profsWithAssis.contains(p)){
profsWithAssis.add(p);
}
}
return profsWithAssis;
}
public int getAmountProfs(){
return profs.size();
}
public int getAmountAssis(){
return assis.size();
}
}
\ No newline at end of file
package io.fp.campus;
public class Professor {
private String name;
private int age;
private boolean isTalking= true;
private String researchArea=null;
private Faculty faculty;
public Professor(String name, int age, String researchArea, Faculty faculty) {
this.name=name;
this.age=age;
this.researchArea=researchArea;
this.faculty=faculty;
}
public void setTalking(boolean isTalking) {
this.isTalking=isTalking;
}
public boolean isTalking() {
return isTalking;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name=name;
}
public String getResearchArea() {
return researchArea;
}
public void setResearchArea(String researchArea) {
this.researchArea=researchArea;
}
public void setFaculty(Faculty faculty) {
this.faculty = faculty;
}
public Faculty getFaculty() {
return this.faculty;
}
public String toString() {
return name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment