add: files from last time and task
This commit is contained in:
@@ -4,6 +4,10 @@
|
|||||||
## Gemacht
|
## Gemacht
|
||||||
*Wir warscheinlich nie aktuell aber egaaaal*
|
*Wir warscheinlich nie aktuell aber egaaaal*
|
||||||
|
|
||||||
|
### 20-11-25 - PHP
|
||||||
|
|
||||||
|
- GETTER in PHP
|
||||||
|
- Übung zu OOP
|
||||||
|
|
||||||
### 19-11-25 - PHP
|
### 19-11-25 - PHP
|
||||||
|
|
||||||
|
|||||||
58
Zweites Jahr/Rechteck.class.php
Executable file
58
Zweites Jahr/Rechteck.class.php
Executable file
@@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
class Rechteck
|
||||||
|
{
|
||||||
|
//Attribute
|
||||||
|
private float $seiteA;
|
||||||
|
private float $seiteB;
|
||||||
|
private string $farbe;
|
||||||
|
|
||||||
|
//SET-Methoden
|
||||||
|
public function setSeiteA($sA)
|
||||||
|
{
|
||||||
|
//Plausibilitätskontrolle
|
||||||
|
if($sA<0){$sA*=-1;}
|
||||||
|
$this->seiteA=$sA;
|
||||||
|
}
|
||||||
|
public function setSeiteB($sB)
|
||||||
|
{
|
||||||
|
$this->seiteB=$sB;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function setFarbe($f)
|
||||||
|
{
|
||||||
|
$this->farbe=$f;
|
||||||
|
}
|
||||||
|
|
||||||
|
// GET-Methoden
|
||||||
|
|
||||||
|
public function getSeiteA(): float
|
||||||
|
{
|
||||||
|
return $this->seiteA;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSeiteB(): float
|
||||||
|
{
|
||||||
|
return $this->seiteB;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFarbe(): string
|
||||||
|
{
|
||||||
|
return $this->farbe;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Andere Methoden
|
||||||
|
public function showFlaeche()
|
||||||
|
{
|
||||||
|
//$seiteA=$this-seiteA;
|
||||||
|
$ergebnis=$this->seiteA*$this->seiteB;
|
||||||
|
|
||||||
|
echo "<p>{$this->seiteA} * {$this->seiteB} = {$ergebnis}</p>";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
24
Zweites Jahr/TestRechteck.php
Executable file
24
Zweites Jahr/TestRechteck.php
Executable file
@@ -0,0 +1,24 @@
|
|||||||
|
<h1>Test Rechteck</h1>
|
||||||
|
<?php
|
||||||
|
include("Rechteck.class.php");
|
||||||
|
|
||||||
|
|
||||||
|
//Objekt instanzi(i)eren
|
||||||
|
$re1 = new Rechteck();
|
||||||
|
$re1->setSeiteA(-5.3);
|
||||||
|
$re1->setSeiteB(10.3);
|
||||||
|
//$re1->seiteA=5.3;
|
||||||
|
//$re1->seiteB=10.3;
|
||||||
|
$re1->showFlaeche();
|
||||||
|
echo "{$re1->getSeiteA()} <br>";
|
||||||
|
echo "{$re1->getSeiteB()} <br>";
|
||||||
|
|
||||||
|
$re2 = new Rechteck();
|
||||||
|
$re2->setSeiteA(500.0);
|
||||||
|
$re2->setSeiteB(3000.4);
|
||||||
|
//$re2->seiteA=500.0;
|
||||||
|
//$re2->seiteB=3000.4;
|
||||||
|
$re2->showFlaeche();
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
60
Zweites Jahr/uebung_konto/konto.class.php
Normal file
60
Zweites Jahr/uebung_konto/konto.class.php
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
|
||||||
|
class Konto{
|
||||||
|
|
||||||
|
private string $iban;
|
||||||
|
private string $kontoInhaber;
|
||||||
|
private float $kontoStand;
|
||||||
|
private float $dispoRahmen;
|
||||||
|
|
||||||
|
public function __construct(string $cIban, string $cInhaber, float $cdispo) {
|
||||||
|
$this->iban = $cIban;
|
||||||
|
$this->kontoInhaber = $cInhaber;
|
||||||
|
$this->dispoRahmen = $cdispo;
|
||||||
|
$this->kontoStand = 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// SETTER
|
||||||
|
public function setDispoRahmen(float $sDispo){
|
||||||
|
$this->dispoRahmen = $sDispo;
|
||||||
|
}
|
||||||
|
|
||||||
|
// GETTER
|
||||||
|
public function getIban():string {
|
||||||
|
return $this->iban;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getKontoInhaber():string {
|
||||||
|
return $this->kontoInhaber;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getDispoRahmen():string {
|
||||||
|
return $this->dispoRahmen;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Methoden
|
||||||
|
|
||||||
|
public function einzahlen(float $betrag){
|
||||||
|
$this->kontoStand += $betrag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function auszahlen(float $betrag) {
|
||||||
|
if ($betrag >= $this->kontoStand){
|
||||||
|
$this->kontoStand -= $betrag;
|
||||||
|
} else if ($betrag >= $this->dispoRahmen){
|
||||||
|
$this->dispoRahmen -= $betrag;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function ausgeben(){
|
||||||
|
echo "<h1> Kontodaten: </h1>";
|
||||||
|
echo "<p><strong>IBAN:</strong> $this->iban</p>";
|
||||||
|
echo "<p><strong>Kontoinhaber:</strong> $this->kontoInhaber</p>";
|
||||||
|
echo "<p><strong>Disporahmen:</strong> $this->dispoRahmen</p>";
|
||||||
|
echo "<p><strong>Kontostand:</strong> $this->kontoStand</p>";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
10
Zweites Jahr/uebung_konto/konto.php
Normal file
10
Zweites Jahr/uebung_konto/konto.php
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<h1>Übung: Konto</h1>
|
||||||
|
|
||||||
|
<?php
|
||||||
|
require_once("konto.class.php");
|
||||||
|
|
||||||
|
$bank = new Konto("DE2498276498237", "Michael Staudt", 1000);
|
||||||
|
$bank->einzahlen(1000);
|
||||||
|
$bank->ausgeben();
|
||||||
|
|
||||||
|
?>
|
||||||
Reference in New Issue
Block a user