zwischen commit

This commit is contained in:
danielvici123
2025-04-02 11:52:21 +02:00
parent 51468e220a
commit a0ac34f313
2 changed files with 65 additions and 9 deletions

View File

@@ -11,26 +11,57 @@ class mitarbeiter {
$this->gehalt = $g;
}
public function getInfo(): string {
public function getInfo():void {
echo "Name: $this->name";
echo "Geburtsdatum: $this->geburtsdatum";
echo" Gehalt: $this->gehalt";
}
public function getJahresgehalt(): string {
echo $this->gehalt * 12;
public function getJahresgehalt():int {
return $this->gehalt * 12;
}
}
class vollzeit extends mitarbeiter {
public string $arbeitszeit =40;
public string $arbeitszeit = 40;
public int $bonus;
public function __construct(string $n, string $gb, string $g) {
public function __construct(string $n, string $gb, string $g, int $b) {
parent::__construct($n, $gb, $g);
$this->name = $n;
$this->geburtsdatum = $gb;
$this->gehalt = $g;
$this->arbeitszeit = 40;
$this->bonus = $b;
}
public function getInfo(): void {
parent::getInfo();
echo "Arbeitszeit: $this->arbeitszeit";
echo "Bonus: $this->bonus";
}
public function getJahresgehalt():int {
return parent::getJahresgehalt() + $this->bonus;
}
}
class teilzeit extends mitarbeiter {
public string $arbeitszeit; // h pro woche
public int $stundenlohn = 15; // Euro pro Stunde
private int $gehalt = 0;
public function __construct(string $n, string $gb, string $g, int $hpw, int $sl) {
parent::__construct($n, $gb, $g);
$this->gehalt = $this->gehalt + ($hpw * $sl * 4); // 4 Wochen pro Monat
$this->stundenlohn = $sl;
}
public function getInfo(): void {
parent::getInfo();
echo "Arbeitszeit: $this->arbeitszeit";
echo "Stundenlohn: $this->stundenlohn";
}
public function getJahresgehalt():int {
return parent::getJahresgehalt() + ($this->stundenlohn * 20 * 12);
}
}
?>

View File

@@ -0,0 +1,25 @@
<!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 'a2_klassen.php';
echo "<h2>Daniel</h2>";
$vz = new vollzeit("Daniel", "2000-01-01", 3000, 1000);
$vz->getInfo();
echo "<br>";
echo "<h2>Aurelion Sol</h2>";
$tz = new teilzeit("Aurelion Sol", "2000-01-01", 3000, 20, 15);
$tz->getInfo();
?>
<br>
<p>Über mir sollte php code ausgeführt werden</p>
</body>
</html>