Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class Vorlesung
- {
- // Properties, alle sind private ==> Information Hiding
- private $name;
- private $nr;
- private $dozent;
- private $teilnehmer = array();
- private $medien;
- // Setter für $name property
- public function setName($name) {
- $this->name = $name;
- }
- // Getter für $name property
- public function getName() {
- return $this->name;
- }
- // Setter für $nr property
- public function setNr($nr) {
- $this->nr = $nr;
- }
- // Getter für $nr property
- public function getNr() {
- return $this->nr;
- }
- // Ausgabe der Details einer Instanz / Wird nicht benötigt
- /*public function printDetails() {
- printf("Die Vorlesung %s (%s) findet heute statt. ", $this->name, $this->nr);
- printf("Die Teilnehmer sind: <ul>");
- foreach ($this->teilnehmer as $tn) { //nicht notwendig bei unserem Beisspiel
- printf("<li>%s</li>", $tn->getNachname);
- }
- echo "</ul>";
- }
- */
- // Setter für einzelneTeilnehmer;
- public function addTeilnehmer($tn) {
- $this->teilnehmer[] = $tn;
- }
- // Setter für das Hinzufügen von mehreren Teilnehmern gleichzeitig per Array $tn
- public function addTeilnehmerArray($tn) {
- $this->teilnehmer = array_merge($this->teilnehmer, $tn);
- }
- // Getter für Teilnehmer;
- public function getTeilnehmer() {
- return $this->teilnehmer;
- }
- // Konstruktor
- public function __construct($nr, $name, $dozent) { //getter und setter fehlen für $nr und $dozent weshalb diese später nicht augegeben werden
- $this->nr = $nr;
- $this->name = $name;
- $this->dozent = $dozent;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement