mirror of
https://github.com/janunger/rheinwerk-video-training.git
synced 2026-02-05 22:55:14 +01:00
Initiale Version
This commit is contained in:
12
Kapitel_4/Lektion_2/1_klassen.php
Normal file
12
Kapitel_4/Lektion_2/1_klassen.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
class MeineKlasse
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
$erstesObjekt = new MeineKlasse();
|
||||
$zweitesObjekt = new MeineKlasse();
|
||||
|
||||
var_dump($erstesObjekt);
|
||||
var_dump($zweitesObjekt);
|
||||
44
Kapitel_4/Lektion_2/2_eigenschaften_und_methoden.php
Normal file
44
Kapitel_4/Lektion_2/2_eigenschaften_und_methoden.php
Normal file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
class Foto
|
||||
{
|
||||
private $dateiname;
|
||||
|
||||
private $tags = 'Natur';
|
||||
|
||||
public function __construct($dateiname)
|
||||
{
|
||||
$this->dateiname = $dateiname;
|
||||
}
|
||||
|
||||
public function getTags()
|
||||
{
|
||||
return $this->tags;
|
||||
}
|
||||
|
||||
public function setTags($tags)
|
||||
{
|
||||
$this->tags = $tags;
|
||||
}
|
||||
|
||||
public function getDateiname()
|
||||
{
|
||||
return $this->dateiname;
|
||||
}
|
||||
}
|
||||
|
||||
$foto1 = new Foto('1.jpg');
|
||||
|
||||
$ergebnis = $foto1->getTags();
|
||||
var_dump($ergebnis);
|
||||
|
||||
$foto1->setTags('Natur, Gebäude');
|
||||
var_dump($foto1->getTags());
|
||||
|
||||
var_dump($foto1->getDateiname());
|
||||
|
||||
var_dump($foto1);
|
||||
|
||||
|
||||
$foto2 = new Foto('2.jpg');
|
||||
var_dump($foto2);
|
||||
62
Kapitel_4/Lektion_3/1_objekte_kommunizieren.php
Normal file
62
Kapitel_4/Lektion_3/1_objekte_kommunizieren.php
Normal file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
class Foto
|
||||
{
|
||||
private $dateiname;
|
||||
|
||||
private $tags = 'Natur';
|
||||
|
||||
public function __construct($dateiname)
|
||||
{
|
||||
$this->dateiname = $dateiname;
|
||||
}
|
||||
|
||||
public function getTags()
|
||||
{
|
||||
return $this->tags;
|
||||
}
|
||||
|
||||
public function setTags($tags)
|
||||
{
|
||||
$this->tags = $tags;
|
||||
}
|
||||
|
||||
public function getDateiname()
|
||||
{
|
||||
return $this->dateiname;
|
||||
}
|
||||
|
||||
public function skaliere($maxAbmessung)
|
||||
{
|
||||
$this->loadFile();
|
||||
// image...
|
||||
$this->saveFile();
|
||||
}
|
||||
|
||||
private function loadFile()
|
||||
{
|
||||
// ...
|
||||
}
|
||||
|
||||
private function saveFile()
|
||||
{
|
||||
// ...
|
||||
}
|
||||
}
|
||||
|
||||
class Datenbank
|
||||
{
|
||||
public function speichere(Foto $objekt)
|
||||
{
|
||||
$dateiname = $objekt->getDateiname();
|
||||
$tags = $objekt->getTags();
|
||||
|
||||
// Daten in MySQL speichern
|
||||
// ...
|
||||
}
|
||||
}
|
||||
|
||||
$foto1 = new Foto('1.jpg');
|
||||
$db = new Datenbank();
|
||||
|
||||
$db->speichere($foto1);
|
||||
15
Kapitel_4/Lektion_4/1_datetime.php
Normal file
15
Kapitel_4/Lektion_4/1_datetime.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
$datum = new DateTime();
|
||||
|
||||
var_dump(
|
||||
date('d.m.Y H:i:s')
|
||||
);
|
||||
|
||||
var_dump(
|
||||
$datum->format('d.m.Y H:i:s')
|
||||
);
|
||||
|
||||
var_dump($datum->getTimezone());
|
||||
|
||||
var_dump($datum->getTimestamp());
|
||||
10
Kapitel_4/Lektion_5/1_require/index.php
Normal file
10
Kapitel_4/Lektion_5/1_require/index.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
require __DIR__ . '/src/Controller.php';
|
||||
require __DIR__ . '/src/Datenbank.php';
|
||||
|
||||
$controller = new Controller();
|
||||
$db = new Datenbank();
|
||||
|
||||
var_dump($controller);
|
||||
var_dump($db);
|
||||
6
Kapitel_4/Lektion_5/1_require/src/Controller.php
Normal file
6
Kapitel_4/Lektion_5/1_require/src/Controller.php
Normal file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
class Controller
|
||||
{
|
||||
|
||||
}
|
||||
6
Kapitel_4/Lektion_5/1_require/src/Datenbank.php
Normal file
6
Kapitel_4/Lektion_5/1_require/src/Datenbank.php
Normal file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
class Datenbank
|
||||
{
|
||||
|
||||
}
|
||||
6
Kapitel_4/Lektion_5/1_require/src/Foto.php
Normal file
6
Kapitel_4/Lektion_5/1_require/src/Foto.php
Normal file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
class Foto
|
||||
{
|
||||
|
||||
}
|
||||
5
Kapitel_4/Lektion_5/2_autoload/autoload.php
Normal file
5
Kapitel_4/Lektion_5/2_autoload/autoload.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
spl_autoload_register(function ($klassenname) {
|
||||
require __DIR__ . '/src/' . $klassenname . '.php';
|
||||
});
|
||||
9
Kapitel_4/Lektion_5/2_autoload/index.php
Normal file
9
Kapitel_4/Lektion_5/2_autoload/index.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
require __DIR__ . '/autoload.php';
|
||||
|
||||
$controller = new Controller();
|
||||
$db = new Datenbank();
|
||||
|
||||
var_dump($controller);
|
||||
var_dump($db);
|
||||
6
Kapitel_4/Lektion_5/2_autoload/src/Controller.php
Normal file
6
Kapitel_4/Lektion_5/2_autoload/src/Controller.php
Normal file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
class Controller
|
||||
{
|
||||
|
||||
}
|
||||
6
Kapitel_4/Lektion_5/2_autoload/src/Datenbank.php
Normal file
6
Kapitel_4/Lektion_5/2_autoload/src/Datenbank.php
Normal file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
class Datenbank
|
||||
{
|
||||
|
||||
}
|
||||
6
Kapitel_4/Lektion_5/2_autoload/src/Foto.php
Normal file
6
Kapitel_4/Lektion_5/2_autoload/src/Foto.php
Normal file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
class Foto
|
||||
{
|
||||
|
||||
}
|
||||
5
Kapitel_4/Lektion_6/autoload.php
Normal file
5
Kapitel_4/Lektion_6/autoload.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
spl_autoload_register(function ($klassenname) {
|
||||
require __DIR__ . '/src/' . $klassenname . '.php';
|
||||
});
|
||||
14
Kapitel_4/Lektion_6/index.php
Normal file
14
Kapitel_4/Lektion_6/index.php
Normal file
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
require __DIR__ . '/autoload.php';
|
||||
|
||||
$kuchen = new Kuchen('Schokolade');
|
||||
var_dump($kuchen->getGeschmacksrichtung());
|
||||
|
||||
$kuchen2 = new Geburtstagskuchen('Erdbeer');
|
||||
var_dump($kuchen2->getGeschmacksrichtung());
|
||||
|
||||
var_dump($kuchen2->getAnzahlKerzen());
|
||||
|
||||
$kuchen2->bringeKerzenAn(3);
|
||||
var_dump($kuchen2->getAnzahlKerzen());
|
||||
16
Kapitel_4/Lektion_6/src/Geburtstagskuchen.php
Normal file
16
Kapitel_4/Lektion_6/src/Geburtstagskuchen.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
class Geburtstagskuchen extends Kuchen
|
||||
{
|
||||
private $anzahlKerzen = 0;
|
||||
|
||||
public function bringeKerzenAn($anzahl)
|
||||
{
|
||||
$this->anzahlKerzen = $anzahl;
|
||||
}
|
||||
|
||||
public function getAnzahlKerzen()
|
||||
{
|
||||
return $this->anzahlKerzen;
|
||||
}
|
||||
}
|
||||
16
Kapitel_4/Lektion_6/src/Kuchen.php
Normal file
16
Kapitel_4/Lektion_6/src/Kuchen.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
class Kuchen
|
||||
{
|
||||
private $geschmacksrichtung;
|
||||
|
||||
public function __construct($geschmacksrichtung)
|
||||
{
|
||||
$this->geschmacksrichtung = $geschmacksrichtung;
|
||||
}
|
||||
|
||||
public function getGeschmacksrichtung()
|
||||
{
|
||||
return $this->geschmacksrichtung;
|
||||
}
|
||||
}
|
||||
5
Kapitel_4/Lektion_7/autoload.php
Normal file
5
Kapitel_4/Lektion_7/autoload.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
spl_autoload_register(function ($klassenname) {
|
||||
require __DIR__ . '/src/' . $klassenname . '.php';
|
||||
});
|
||||
8
Kapitel_4/Lektion_7/index.php
Normal file
8
Kapitel_4/Lektion_7/index.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
require __DIR__ . '/autoload.php';
|
||||
|
||||
$motor = new Motor();
|
||||
$auto = new Auto($motor);
|
||||
|
||||
$auto->starte();
|
||||
24
Kapitel_4/Lektion_7/src/Auto.php
Normal file
24
Kapitel_4/Lektion_7/src/Auto.php
Normal file
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
class Auto
|
||||
{
|
||||
/**
|
||||
* @var Motor
|
||||
*/
|
||||
private $motor;
|
||||
|
||||
public function __construct(Motor $motor)
|
||||
{
|
||||
$this->motor = $motor;
|
||||
}
|
||||
|
||||
public function starte()
|
||||
{
|
||||
$this->motor->betaetigeAnlasser();
|
||||
}
|
||||
|
||||
public function fahre($anzahlKilometer, $geschwindigkeit)
|
||||
{
|
||||
// ...
|
||||
}
|
||||
}
|
||||
9
Kapitel_4/Lektion_7/src/Motor.php
Normal file
9
Kapitel_4/Lektion_7/src/Motor.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
class Motor
|
||||
{
|
||||
public function betaetigeAnlasser()
|
||||
{
|
||||
// ...
|
||||
}
|
||||
}
|
||||
6
Kapitel_4/Lektion_8/autoload.php
Normal file
6
Kapitel_4/Lektion_8/autoload.php
Normal file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
spl_autoload_register(function ($klassenname) {
|
||||
$klassenpfad = str_replace('\\', '/', $klassenname);
|
||||
require __DIR__ . '/src/' . $klassenpfad . '.php';
|
||||
});
|
||||
5
Kapitel_4/Lektion_8/index.php
Normal file
5
Kapitel_4/Lektion_8/index.php
Normal file
@@ -0,0 +1,5 @@
|
||||
<?php
|
||||
|
||||
require __DIR__ . '/autoload.php';
|
||||
|
||||
$fahrzeug1 = new \Fahrzeuge\Autos\Limousine();
|
||||
8
Kapitel_4/Lektion_8/src/Fahrzeuge/Auto.php
Normal file
8
Kapitel_4/Lektion_8/src/Fahrzeuge/Auto.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
namespace Fahrzeuge;
|
||||
|
||||
class Auto
|
||||
{
|
||||
|
||||
}
|
||||
10
Kapitel_4/Lektion_8/src/Fahrzeuge/Autos/Kombi.php
Normal file
10
Kapitel_4/Lektion_8/src/Fahrzeuge/Autos/Kombi.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Fahrzeuge\Autos;
|
||||
|
||||
use Fahrzeuge\Auto;
|
||||
|
||||
class Kombi extends Auto
|
||||
{
|
||||
|
||||
}
|
||||
10
Kapitel_4/Lektion_8/src/Fahrzeuge/Autos/Limousine.php
Normal file
10
Kapitel_4/Lektion_8/src/Fahrzeuge/Autos/Limousine.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Fahrzeuge\Autos;
|
||||
|
||||
use Fahrzeuge\Auto;
|
||||
|
||||
class Limousine extends Auto
|
||||
{
|
||||
|
||||
}
|
||||
6
Kapitel_4/Lektion_9/autoload.php
Normal file
6
Kapitel_4/Lektion_9/autoload.php
Normal file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
spl_autoload_register(function ($klassenname) {
|
||||
$klassenpfad = str_replace('\\', '/', $klassenname);
|
||||
require __DIR__ . '/src/' . $klassenpfad . '.php';
|
||||
});
|
||||
9
Kapitel_4/Lektion_9/index.php
Normal file
9
Kapitel_4/Lektion_9/index.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
require __DIR__ . '/autoload.php';
|
||||
|
||||
$autoFactoryService = new AutoFactory();
|
||||
|
||||
$auto1 = $autoFactoryService->baueAuto();
|
||||
$auto2 = $autoFactoryService->baueAuto();
|
||||
$auto3 = $autoFactoryService->baueAuto();
|
||||
8
Kapitel_4/Lektion_9/src/Auto.php
Normal file
8
Kapitel_4/Lektion_9/src/Auto.php
Normal file
@@ -0,0 +1,8 @@
|
||||
<?php
|
||||
|
||||
class Auto
|
||||
{
|
||||
public function __construct(Motor $motor, Getriebe $getriebe)
|
||||
{
|
||||
}
|
||||
}
|
||||
12
Kapitel_4/Lektion_9/src/AutoFactory.php
Normal file
12
Kapitel_4/Lektion_9/src/AutoFactory.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
class AutoFactory
|
||||
{
|
||||
public function baueAuto()
|
||||
{
|
||||
$motor = new Motor();
|
||||
$getriebe = new Getriebe();
|
||||
|
||||
return new Auto($motor, $getriebe);
|
||||
}
|
||||
}
|
||||
6
Kapitel_4/Lektion_9/src/Getriebe.php
Normal file
6
Kapitel_4/Lektion_9/src/Getriebe.php
Normal file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
class Getriebe
|
||||
{
|
||||
|
||||
}
|
||||
6
Kapitel_4/Lektion_9/src/Motor.php
Normal file
6
Kapitel_4/Lektion_9/src/Motor.php
Normal file
@@ -0,0 +1,6 @@
|
||||
<?php
|
||||
|
||||
class Motor
|
||||
{
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user