58 lines
918 B
PHP
Executable File
58 lines
918 B
PHP
Executable File
<?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>";
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
?>
|