From 7043d56329b3901765e6d1c3ec610e2999500f16 Mon Sep 17 00:00:00 2001
From: Kilian Hofmann
Date: Fri, 28 Jun 2024 13:39:21 +0200
Subject: [PATCH] EoD
---
tasks/oop/hyperlink/hyperlink.php | 58 +++++++++++++++++++++++++++++++
tasks/oop/hyperlink/index.php | 33 ++++++++++++++++++
tasks/oop/person/index.php | 23 ++++++++++++
tasks/oop/person/person.php | 33 ++++++++++++++++++
4 files changed, 147 insertions(+)
create mode 100644 tasks/oop/hyperlink/hyperlink.php
create mode 100644 tasks/oop/hyperlink/index.php
create mode 100644 tasks/oop/person/index.php
create mode 100644 tasks/oop/person/person.php
diff --git a/tasks/oop/hyperlink/hyperlink.php b/tasks/oop/hyperlink/hyperlink.php
new file mode 100644
index 0000000..88779ad
--- /dev/null
+++ b/tasks/oop/hyperlink/hyperlink.php
@@ -0,0 +1,58 @@
+uri = $uri;
+ $this->title = $title;
+ $this->setColour($colour);
+ }
+
+ /*
+ * Getters and Setters
+ */
+
+ public function setColour(string $colour = null)
+ {
+ if ($colour === null) {
+ $this->colour = null;
+ return;
+ }
+
+ if (!preg_match("/^#([0-9A-Fa-f]{3,4}|[0-9A-Fa-f]{6}|[0-9A-Fa-f]{8})$/", $colour)) {
+ trigger_error("Colour invalid", E_USER_WARNING);
+ return;
+ }
+
+ $this->colour = $colour;
+ }
+
+ public function getColour()
+ {
+ return $this->colour ?? "No colour specified";
+ }
+
+ /*
+ * Meta
+ */
+
+ public function __toString()
+ {
+ $style = $this->colour ? "style=\"color:$this->colour;\"" : "";
+ return <<$this->title
+ END;
+ }
+}
diff --git a/tasks/oop/hyperlink/index.php b/tasks/oop/hyperlink/index.php
new file mode 100644
index 0000000..409f47b
--- /dev/null
+++ b/tasks/oop/hyperlink/index.php
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+ Person Test
+
+
+
+ $link1
";
+ $link1->setColour("#CC0000");
+ echo "$link1
\n";
+
+ $link2 = new Hyperlink("https://portal.zedat.fu-berlin.de", "Zedat-Portal");
+ echo "$link2
\n";
+
+ $link3 = new Hyperlink("https://userpage.fu-berlin.de/db-admin", "phpMyAdmin", "#009900");
+ echo "Die Farbe des Links $link3 ist " . $link3->getColour() . "
\n";
+ ?>
+
+
+
\ No newline at end of file
diff --git a/tasks/oop/person/index.php b/tasks/oop/person/index.php
new file mode 100644
index 0000000..8e8442d
--- /dev/null
+++ b/tasks/oop/person/index.php
@@ -0,0 +1,23 @@
+
+
+
+
+
+
+ Person Test
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/tasks/oop/person/person.php b/tasks/oop/person/person.php
new file mode 100644
index 0000000..95f7dea
--- /dev/null
+++ b/tasks/oop/person/person.php
@@ -0,0 +1,33 @@
+name = $name;
+ $this->weight = $weight;
+ $this->birthdate = $birthdate;
+ }
+
+ /*
+ * Meta
+ */
+
+ public function __toString()
+ {
+ $formatter = new IntlDateFormatter('en_UK', IntlDateFormatter::SHORT, IntlDateFormatter::SHORT);
+ $formatter->setPattern('E dd.MM.yyyy');
+ return "$this->name, currently {$this->weight}lbs, was born on {$formatter->format($this->birthdate)}";
+ }
+}