Initial commit of the source files.
This commit is contained in:
parent
41a20b4afe
commit
f75be9110e
|
@ -0,0 +1,57 @@
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Diese Klasse verwaltet einen Dozenten und die von ihm betreuten Studenten.
|
||||||
|
* @author Marc Rennhard
|
||||||
|
*/
|
||||||
|
public class Betreuungsverhaeltnis
|
||||||
|
{
|
||||||
|
private Dozent dozent;
|
||||||
|
private ArrayList<Student> studenten;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Erzeuge ein Betreuungsverhaeltnis.
|
||||||
|
* @param dozent Der Dozent
|
||||||
|
*/
|
||||||
|
public Betreuungsverhaeltnis(Dozent dozent)
|
||||||
|
{
|
||||||
|
this.dozent = dozent;
|
||||||
|
studenten = new ArrayList<Student>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fuege einen Studenten hinzu.
|
||||||
|
* @param student Der Student
|
||||||
|
*/
|
||||||
|
public void studentZufuegen(Student student)
|
||||||
|
{
|
||||||
|
studenten.add(student);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verteilt ein gewisse Anzahl Credits zufällig unter den Studenten,
|
||||||
|
* total werden Anzahl Studenten * 40 Credits verteilt.
|
||||||
|
*/
|
||||||
|
public void verteileCredits()
|
||||||
|
{
|
||||||
|
Random random = new Random();
|
||||||
|
|
||||||
|
for(int i = 0; i < (10 * studenten.size()); i++) {
|
||||||
|
studenten.get(random.nextInt(studenten.size())).erhoeheCredits(4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gibt die Informationen dieses Betreuungsverhaeltnisses aus.
|
||||||
|
*/
|
||||||
|
public void ausgeben()
|
||||||
|
{
|
||||||
|
System.out.println("Dozent " + dozent.gibInfo() + ", Buero " + dozent.gibBuero() +
|
||||||
|
", Telefon: " + dozent.gibTelefonnummer());
|
||||||
|
System.out.println("betreut " + studenten.size() + " Studenten:");
|
||||||
|
for (Student student : studenten) {
|
||||||
|
System.out.println(student.gibInfo() + ", " + student.gibCredits() + " credits");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
public class Simulation
|
||||||
|
{
|
||||||
|
Betreuungsverhaeltnis betreuungsverhaeltnis;
|
||||||
|
|
||||||
|
public Simulation()
|
||||||
|
{
|
||||||
|
Dozent dozent = new Dozent("Albert Einstein", "1234-5678", "TG210", "058-9347259");
|
||||||
|
betreuungsverhaeltnis = new Betreuungsverhaeltnis(dozent);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void simulieren()
|
||||||
|
{
|
||||||
|
betreuungsverhaeltnis.studentZufuegen(new Student("Adam Alder", "abcd-efgh"));
|
||||||
|
betreuungsverhaeltnis.studentZufuegen(new Student("Bea Bingo", "ace-gikm"));
|
||||||
|
betreuungsverhaeltnis.studentZufuegen(new Student("Clea Clever", "bdfh-jlnp"));
|
||||||
|
betreuungsverhaeltnis.studentZufuegen(new Student("Dino Dasen", "qwer-tzui"));
|
||||||
|
betreuungsverhaeltnis.studentZufuegen(new Student("Eva Ente", "asdf-ghjk"));
|
||||||
|
betreuungsverhaeltnis.studentZufuegen(new Student("Fritz Floh", "yxcv-bnmm"));
|
||||||
|
betreuungsverhaeltnis.studentZufuegen(new Student("Geri Gugger", "uvwa-xyzb"));
|
||||||
|
betreuungsverhaeltnis.verteileCredits();
|
||||||
|
betreuungsverhaeltnis.ausgeben();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void main(String[] args)
|
||||||
|
{
|
||||||
|
(new Simulation()).simulieren();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue