From a0ac34f3132067fcf8ead74501bf4520aa4c1fc2 Mon Sep 17 00:00:00 2001 From: danielvici123 <94993276+danielvici@users.noreply.github.com> Date: Wed, 2 Apr 2025 11:52:21 +0200 Subject: [PATCH] zwischen commit --- progp/25-4-2 - oop/a2_klassen.php | 49 +++++++++++++++++++++++++------ progp/25-4-2 - oop/a2_test.php | 25 ++++++++++++++++ 2 files changed, 65 insertions(+), 9 deletions(-) create mode 100644 progp/25-4-2 - oop/a2_test.php diff --git a/progp/25-4-2 - oop/a2_klassen.php b/progp/25-4-2 - oop/a2_klassen.php index d19fb9e..59a8f60 100644 --- a/progp/25-4-2 - oop/a2_klassen.php +++ b/progp/25-4-2 - oop/a2_klassen.php @@ -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); } } ?> \ No newline at end of file diff --git a/progp/25-4-2 - oop/a2_test.php b/progp/25-4-2 - oop/a2_test.php new file mode 100644 index 0000000..ae5f828 --- /dev/null +++ b/progp/25-4-2 - oop/a2_test.php @@ -0,0 +1,25 @@ + + + +
+ + +Über mir sollte php code ausgeführt werden
+ + \ No newline at end of file