aufgaben weil vergesen zu commiten
This commit is contained in:
36
progp/25-4-2 - oop/a2_klassen.php
Normal file
36
progp/25-4-2 - oop/a2_klassen.php
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
ini_set("display_errors", "on");
|
||||
class mitarbeiter {
|
||||
public string $name;
|
||||
public string $geburtsdatum;
|
||||
public string $gehalt;
|
||||
|
||||
public function __construct(string $n, string $gb, string $g) {
|
||||
$this->name = $n;
|
||||
$this->geburtsdatum = $gb;
|
||||
$this->gehalt = $g;
|
||||
}
|
||||
|
||||
public function getInfo(): string {
|
||||
echo "Name: $this->name";
|
||||
echo "Geburtsdatum: $this->geburtsdatum";
|
||||
echo" Gehalt: $this->gehalt";
|
||||
}
|
||||
|
||||
public function getJahresgehalt(): string {
|
||||
echo $this->gehalt * 12;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class vollzeit extends mitarbeiter {
|
||||
public string $arbeitszeit =40;
|
||||
|
||||
public function __construct(string $n, string $gb, string $g) {
|
||||
parent::__construct($n, $gb, $g);
|
||||
$this->name = $n;
|
||||
$this->geburtsdatum = $gb;
|
||||
$this->gehalt = $g;
|
||||
}
|
||||
}
|
||||
?>
|
||||
14
progp/25-4-2 - oop/teilnehmer.php
Normal file
14
progp/25-4-2 - oop/teilnehmer.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
ini_set("display_errors", "on");
|
||||
class teilnehmer {
|
||||
public string $name;
|
||||
public string $vorname;
|
||||
public string $code;
|
||||
|
||||
public function __construct(string $n, string $vn, string $c) {
|
||||
$this->name = $n;
|
||||
$this->vorname = $vn;
|
||||
$this->code = $c;
|
||||
}
|
||||
}
|
||||
?>
|
||||
26
progp/25-4-2 - oop/testteilnehmer.php
Normal file
26
progp/25-4-2 - oop/testteilnehmer.php
Normal file
@@ -0,0 +1,26 @@
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Teilnehmer</h1>
|
||||
<?php
|
||||
ini_set("display_errors", "on");
|
||||
require_once 'teilnehmer.php';
|
||||
require_once 'tnintern.php';
|
||||
echo "<h2>Daniel</h2>";
|
||||
$tl = new tnintern("vici123", "daniel", "2BKI1", "IT");
|
||||
$tl->getDaten();
|
||||
echo "<br>";
|
||||
echo "<h2>Aurelion Sol</h2>";
|
||||
$tl = new tnintern("sol", "aurelion", "mage", "midde");
|
||||
$tl->getDaten();
|
||||
?>
|
||||
<br>
|
||||
<p>Über mir sollte php code ausgeführt werden</p>
|
||||
</body>
|
||||
</html>
|
||||
26
progp/25-4-2 - oop/tnintern.php
Normal file
26
progp/25-4-2 - oop/tnintern.php
Normal file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
require_once 'teilnehmer.php';
|
||||
ini_set("display_errors", "on");
|
||||
class tnintern extends teilnehmer {
|
||||
private string $abteilung;
|
||||
private int $anzahl=0;
|
||||
|
||||
public function __construct($n, $vn, $c ,$abteilung) {
|
||||
parent::__construct($vn, $n, $c);
|
||||
$this->abteilung = $abteilung;
|
||||
$this->anzahl= $this->anzahl+1;
|
||||
}
|
||||
|
||||
public function getDaten() {
|
||||
echo "Name: $this->name <br>";
|
||||
echo "Vorname: $this->vorname <br>";
|
||||
echo "Code: $this->code <br>";
|
||||
echo "Abteilung: $this->abteilung <br>";
|
||||
echo "Anzahl: $this->anzahl";
|
||||
}
|
||||
|
||||
public function getAnzahl():int {
|
||||
return $this->anzahl;
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user