diff --git a/abstract-class.php b/abstract-class.php
new file mode 100644
index 0000000..97518ee
--- /dev/null
+++ b/abstract-class.php
@@ -0,0 +1,44 @@
+name = $name;
+ $this->whiskerType = $whiskerType;
+ }
+ abstract public function whoAreYou() : string;
+}
+
+// Child classes
+class Leon extends Feline {
+ public function whoAreYou() : string {
+ return "I'm a king! I'm a $this->name!";
+ }
+}
+
+class Pantera extends Feline {
+ public function whoAreYou() : string {
+ return "I'm a very fast ! I'm a $this->name!";
+ }
+}
+
+class Tiger extends Feline {
+ public function whoAreYou() : string {
+ return "I'm a cute! I'm a $this->name!";
+ }
+}
+
+// Create objects from the child classes
+/*$leon = new Leon("Leon", "long");
+echo $leon->whoAreYou();
+echo "
";
+
+$pantera = new Pantera("Pantera", "median");
+echo $pantera->whoAreYou();
+echo "
";
+
+$tiger = new Tiger("Tiger", "very long");
+echo $tiger->whoAreYou();*/
+?>
diff --git a/animal-class.php b/animal-class.php
new file mode 100644
index 0000000..524bcfa
--- /dev/null
+++ b/animal-class.php
@@ -0,0 +1,66 @@
+name=$name;
+ $this->type=$type;
+ $this->age=$age;
+ $this->vertebrates=$vertebrates;
+ $this->warmBlooded=$warmBlooded;
+}
+
+
+public function showAnimal(string $name, string $type, $age, bool $vertebrates, bool $warmBlooded){
+ $subType = true;
+ $blood = true;
+ if ($vertebrates === true){
+ $subType = "vertebrates";
+ }else{
+ $subType = "invertebrates";
+ }
+
+ if( $warmBlooded === true){
+ $blood = "warm-blooded";
+ }else{
+ $blood = "cold-blooded";
+ }
+
+echo "
+
How Do $name Breathe?
$breath"; +} + +public function canMove(string $name, string $movement){ + echo "How Do $name move?
$movement"; +} + +public function makeSound(string $name, string $sound){ + echo "Does $name make any sound?
$sound"; +} + + + + +public function __destruct(){ + print "Destruct " . __CLASS__ . "\n"; +} +} + +?> + + diff --git a/animal-object.php b/animal-object.php new file mode 100644 index 0000000..7978855 --- /dev/null +++ b/animal-object.php @@ -0,0 +1,78 @@ + + + + + + + + + +ABSTRACT CLASS
"; +$leon = new Leon("Leon", "long"); +echo $leon->whoAreYou(); +echo "How speaks a $name?
$sound"; + return $sound; +} + +} + +?> \ No newline at end of file diff --git a/ejemple.php b/ejemple.php new file mode 100644 index 0000000..6d8e2f6 --- /dev/null +++ b/ejemple.php @@ -0,0 +1,176 @@ +// create php Base class that will be inherited at least once. +This base case must have at least: +3 properties +3 methods +1 constructor and 1 destructor // + +property1 = $p1; + $this->property2 = $p2; + $this->property3 = $p3; + } + + public function method1() { + // code here + } + + public function method2() { + // code here + } + + public function method3() { + // code here + } + + public function __destruct() { + // code here + } +} +?> + +// create php class that inherits the base class. +This class must add: +1 static property +1 method // + +property2 = $p2; + } + + public function newMethod() { + // code here + } + + public function method2() { + // code here (override) + } + } + ?> + +// One abstract class with at least: +2 properties +2 methods +// + +property1 = $p1; + $this->property2 = $p2; + } + + abstract public function method1(); + + abstract public function method2(); + } + +?> + + +// One interface that must be implemented by one class. +This interface must have at least 2 methods. // + + + + +// Other option with interface and inheretence // + +age = $age; + $this->fur = $fur; + $this->vertebrates = $vertebrates; + $this->type = $type; + } + + public function __destruct() { + // code here + } + + public function breath() { + // code here + } + + public function move() { + // code here + } + + public function sound() { + // code here + } +} + +class Cat extends Animal { + protected $breed; + + public function __construct($age, $fur, $vertebrates, $type, $breed) { + parent::__construct($age, $fur, $vertebrates, $type); + $this->breed = $breed; + } + + public function purr() { + // code here + } + + public function sound() { + // code here (override) + } + + public function meow() { + // code here + } +} + +abstract class Feline extends Cat { + protected $whisker_type; + + public function throwObjectInstance() { + // code here + } +} + +?> \ No newline at end of file diff --git a/01-classes.php b/ejemplos/01-classes.php similarity index 100% rename from 01-classes.php rename to ejemplos/01-classes.php diff --git a/02-properties.php b/ejemplos/02-properties.php similarity index 100% rename from 02-properties.php rename to ejemplos/02-properties.php diff --git a/03-methods.php b/ejemplos/03-methods.php similarity index 100% rename from 03-methods.php rename to ejemplos/03-methods.php diff --git a/04-getters.php b/ejemplos/04-getters.php similarity index 100% rename from 04-getters.php rename to ejemplos/04-getters.php diff --git a/05-setters.php b/ejemplos/05-setters.php similarity index 100% rename from 05-setters.php rename to ejemplos/05-setters.php diff --git a/06-constructors.php b/ejemplos/06-constructors.php similarity index 100% rename from 06-constructors.php rename to ejemplos/06-constructors.php diff --git a/07-inheritance-problem.php b/ejemplos/07-inheritance-problem.php similarity index 100% rename from 07-inheritance-problem.php rename to ejemplos/07-inheritance-problem.php diff --git a/08-inheritance-solution.php b/ejemplos/08-inheritance-solution.php similarity index 100% rename from 08-inheritance-solution.php rename to ejemplos/08-inheritance-solution.php diff --git a/09-public-private-protected.php b/ejemplos/09-public-private-protected.php similarity index 100% rename from 09-public-private-protected.php rename to ejemplos/09-public-private-protected.php diff --git a/10-static.php b/ejemplos/10-static.php similarity index 100% rename from 10-static.php rename to ejemplos/10-static.php diff --git a/11-const.php b/ejemplos/11-const.php similarity index 100% rename from 11-const.php rename to ejemplos/11-const.php diff --git a/12-abstract-classes.php b/ejemplos/12-abstract-classes.php similarity index 100% rename from 12-abstract-classes.php rename to ejemplos/12-abstract-classes.php diff --git a/13-interfaces.php b/ejemplos/13-interfaces.php similarity index 100% rename from 13-interfaces.php rename to ejemplos/13-interfaces.php diff --git a/14-overriding.php b/ejemplos/14-overriding.php similarity index 100% rename from 14-overriding.php rename to ejemplos/14-overriding.php diff --git a/15-overloading.php b/ejemplos/15-overloading.php similarity index 100% rename from 15-overloading.php rename to ejemplos/15-overloading.php diff --git a/16-namespaces.php b/ejemplos/16-namespaces.php similarity index 100% rename from 16-namespaces.php rename to ejemplos/16-namespaces.php diff --git a/mobileLibs.php b/ejemplos/mobileLibs.php similarity index 100% rename from mobileLibs.php rename to ejemplos/mobileLibs.php diff --git a/interface.php b/interface.php new file mode 100644 index 0000000..68f2016 --- /dev/null +++ b/interface.php @@ -0,0 +1,31 @@ +Dog likes meat