From a80ce04bac22cd5ccbd0cf71e1888eb2cf1458a4 Mon Sep 17 00:00:00 2001 From: Jesus Velazquez Date: Thu, 26 Jan 2023 17:33:30 +0100 Subject: [PATCH 1/4] inicio --- index.php | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 index.php diff --git a/index.php b/index.php new file mode 100644 index 0000000..176c8a7 --- /dev/null +++ b/index.php @@ -0,0 +1,6 @@ + \ No newline at end of file From 18b9212127d1f7d53fb1d8510415b2bc8952a0a3 Mon Sep 17 00:00:00 2001 From: Jesus Velazquez Date: Thu, 26 Jan 2023 17:33:34 +0100 Subject: [PATCH 2/4] begining --- 01-classes.php => examples/01-classes.php | 0 02-properties.php => examples/02-properties.php | 0 03-methods.php => examples/03-methods.php | 0 04-getters.php => examples/04-getters.php | 0 05-setters.php => examples/05-setters.php | 0 06-constructors.php => examples/06-constructors.php | 0 07-inheritance-problem.php => examples/07-inheritance-problem.php | 0 .../08-inheritance-solution.php | 0 .../09-public-private-protected.php | 0 10-static.php => examples/10-static.php | 0 11-const.php => examples/11-const.php | 0 12-abstract-classes.php => examples/12-abstract-classes.php | 0 13-interfaces.php => examples/13-interfaces.php | 0 14-overriding.php => examples/14-overriding.php | 0 15-overloading.php => examples/15-overloading.php | 0 16-namespaces.php => examples/16-namespaces.php | 0 mobileLibs.php => examples/mobileLibs.php | 0 17 files changed, 0 insertions(+), 0 deletions(-) rename 01-classes.php => examples/01-classes.php (100%) rename 02-properties.php => examples/02-properties.php (100%) rename 03-methods.php => examples/03-methods.php (100%) rename 04-getters.php => examples/04-getters.php (100%) rename 05-setters.php => examples/05-setters.php (100%) rename 06-constructors.php => examples/06-constructors.php (100%) rename 07-inheritance-problem.php => examples/07-inheritance-problem.php (100%) rename 08-inheritance-solution.php => examples/08-inheritance-solution.php (100%) rename 09-public-private-protected.php => examples/09-public-private-protected.php (100%) rename 10-static.php => examples/10-static.php (100%) rename 11-const.php => examples/11-const.php (100%) rename 12-abstract-classes.php => examples/12-abstract-classes.php (100%) rename 13-interfaces.php => examples/13-interfaces.php (100%) rename 14-overriding.php => examples/14-overriding.php (100%) rename 15-overloading.php => examples/15-overloading.php (100%) rename 16-namespaces.php => examples/16-namespaces.php (100%) rename mobileLibs.php => examples/mobileLibs.php (100%) diff --git a/01-classes.php b/examples/01-classes.php similarity index 100% rename from 01-classes.php rename to examples/01-classes.php diff --git a/02-properties.php b/examples/02-properties.php similarity index 100% rename from 02-properties.php rename to examples/02-properties.php diff --git a/03-methods.php b/examples/03-methods.php similarity index 100% rename from 03-methods.php rename to examples/03-methods.php diff --git a/04-getters.php b/examples/04-getters.php similarity index 100% rename from 04-getters.php rename to examples/04-getters.php diff --git a/05-setters.php b/examples/05-setters.php similarity index 100% rename from 05-setters.php rename to examples/05-setters.php diff --git a/06-constructors.php b/examples/06-constructors.php similarity index 100% rename from 06-constructors.php rename to examples/06-constructors.php diff --git a/07-inheritance-problem.php b/examples/07-inheritance-problem.php similarity index 100% rename from 07-inheritance-problem.php rename to examples/07-inheritance-problem.php diff --git a/08-inheritance-solution.php b/examples/08-inheritance-solution.php similarity index 100% rename from 08-inheritance-solution.php rename to examples/08-inheritance-solution.php diff --git a/09-public-private-protected.php b/examples/09-public-private-protected.php similarity index 100% rename from 09-public-private-protected.php rename to examples/09-public-private-protected.php diff --git a/10-static.php b/examples/10-static.php similarity index 100% rename from 10-static.php rename to examples/10-static.php diff --git a/11-const.php b/examples/11-const.php similarity index 100% rename from 11-const.php rename to examples/11-const.php diff --git a/12-abstract-classes.php b/examples/12-abstract-classes.php similarity index 100% rename from 12-abstract-classes.php rename to examples/12-abstract-classes.php diff --git a/13-interfaces.php b/examples/13-interfaces.php similarity index 100% rename from 13-interfaces.php rename to examples/13-interfaces.php diff --git a/14-overriding.php b/examples/14-overriding.php similarity index 100% rename from 14-overriding.php rename to examples/14-overriding.php diff --git a/15-overloading.php b/examples/15-overloading.php similarity index 100% rename from 15-overloading.php rename to examples/15-overloading.php diff --git a/16-namespaces.php b/examples/16-namespaces.php similarity index 100% rename from 16-namespaces.php rename to examples/16-namespaces.php diff --git a/mobileLibs.php b/examples/mobileLibs.php similarity index 100% rename from mobileLibs.php rename to examples/mobileLibs.php From e66402e047893ab3d3a707981a4c749c11401396 Mon Sep 17 00:00:00 2001 From: Jesus Velazquez Date: Tue, 31 Jan 2023 09:50:17 +0100 Subject: [PATCH 3/4] finished --- Interface.php | 8 +++++++ Plays.php | 46 +++++++++++++++++++++++++++++++++++++++ Spectacles.php | 20 +++++++++++++++++ StageSpectacles.php | 52 +++++++++++++++++++++++++++++++++++++++++++++ index.php | 42 +++++++++++++++++++++++++++++++++++- template.txt | 17 +++++++++++++++ 6 files changed, 184 insertions(+), 1 deletion(-) create mode 100644 Interface.php create mode 100644 Plays.php create mode 100644 Spectacles.php create mode 100644 StageSpectacles.php create mode 100644 template.txt diff --git a/Interface.php b/Interface.php new file mode 100644 index 0000000..cb17257 --- /dev/null +++ b/Interface.php @@ -0,0 +1,8 @@ + \ No newline at end of file diff --git a/Plays.php b/Plays.php new file mode 100644 index 0000000..4615edf --- /dev/null +++ b/Plays.php @@ -0,0 +1,46 @@ +author = $author; + } + + public function welcome():string{ + return "Welcome to the Apollo Theater 2023 programme."; + } + + public function setDate($date){ /* :string */ + $this->datePremiere = $date; + } + + public function getDate(){ /* :string */ + return "The premiere date is : ".$this->datePremiere."."; + } + + public function getType(){ + $this->category=="drama"? + $this->isPlay(): $this->isNotPlay(); + } + + public function isPlay(){ + echo "
It is a play.

"; + } + + public function isNotPlay(){ + echo "
It is not a play.

"; + } + + public function __destruct(){ + + } +} + +?> \ No newline at end of file diff --git a/Spectacles.php b/Spectacles.php new file mode 100644 index 0000000..445f997 --- /dev/null +++ b/Spectacles.php @@ -0,0 +1,20 @@ +spectacleName = $spectacleName; + $this->spectacleType = $spectacleType; + } + + abstract function printCategory():string; + abstract function printCompany():string; +} + +?> \ No newline at end of file diff --git a/StageSpectacles.php b/StageSpectacles.php new file mode 100644 index 0000000..ac174d5 --- /dev/null +++ b/StageSpectacles.php @@ -0,0 +1,52 @@ +category = $category; + $this->performersNumber = $performersNumber; + $this->company = $company; + } + + public function welcome():string{ + return "To reach the Apollo Theater 2023 programme, please supply more information."; + } + + public function spectacleNameAndType():string{ + return "This " . self::SPECTACLE . " is called " . $this->spectacleName . " and is of type " . $this->spectacleType . ".
"; + } + + public function printCategory():string{ + return $this->category=="drama"? + "This play is of category: ".$this->category.".": + "This perform is of category: ".$this->category."."; + } + + public function ensembleSize():string{ + return $this->performersNumber<10? + "

This play has ".$this->performersNumber." performers and therefore is a small ensemble. Please update the number of performers for the Apollo Theater to accept this play.": + "

This play has ".$this->performersNumber." performers and therefore is a big ensemble."; + } + + public function updatePerformers($newPerformersNumber){ + $this->performersNumber = $newPerformersNumber; + return $this->performersNumber<10? "Please update again. ".$this->performersNumber." performer is not enough." : "This amount of performers is perfect."; + } + + public function printCompany():string{ + return "

The company's name is: ".$this->company."."; + } + + public function __destruct(){ + echo "

The " . self::SPECTACLE . "/s has/have been successfully registered" . ".

"; + } +} + +?> \ No newline at end of file diff --git a/index.php b/index.php index 176c8a7..83ceee7 100644 --- a/index.php +++ b/index.php @@ -1,6 +1,46 @@ Plase introduce the registration information.

"; +echo "
"; +echo "
"; +$spectacle = New StageSpectacles("Macbeth", "stage", "drama", 9, "ububu"); +echo "
"; +echo $spectacle->welcome(); +echo "

"; +$macbeth = New Plays("Macbeth", "stage", "drama", 9, "ububu", "Shakespeare"); +$macbeth->setDate("3-2-2024"); +echo $macbeth->spectacleNameAndType(); +echo "
"; +echo $macbeth->welcome(); +echo "
"; +echo $macbeth->getType(); +echo $macbeth->printCategory(); +echo $macbeth->printCompany(); +echo $macbeth->ensembleSize(); +echo "

"; +echo $macbeth->updatePerformers(8); +echo "

"; +echo $macbeth->updatePerformers(12); +echo "

"; +echo $macbeth->getDate(); - +echo "

"; +echo "
"; +$ubuRoi = New Plays("Ubu Roi", "visual", "absurd", 15, "La Infantona", "Alfred Jarry"); +$ubuRoi->setDate("12-6-2023"); +echo "
"; +echo $ubuRoi->spectacleNameAndType(); +echo "
"; +echo $ubuRoi->welcome(); +echo "
"; +echo $ubuRoi->getType(); +echo $ubuRoi->printCategory(); +echo $ubuRoi->printCompany(); +echo $ubuRoi->ensembleSize(); +echo "

"; +echo $ubuRoi->getDate(); ?> \ No newline at end of file diff --git a/template.txt b/template.txt new file mode 100644 index 0000000..4ccbd59 --- /dev/null +++ b/template.txt @@ -0,0 +1,17 @@ +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 +One class that inherits the base class. +This class must add: +1 static property +1 method +This class must override: +1 property +1 method +One abstract class with at least: +2 properties +2 methods +One interface that must be implemented by one class. +This interface must have at least 2 method From 86097d1b2dd61b7ed659862ca60b5c2ea1b11d3e Mon Sep 17 00:00:00 2001 From: Jesus Velazquez Date: Tue, 31 Jan 2023 10:05:48 +0100 Subject: [PATCH 4/4] readme --- README.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/README.md b/README.md index e644e6a..70d9682 100644 --- a/README.md +++ b/README.md @@ -134,3 +134,14 @@ Namespaces are qualifiers that solve two different problems: 2. They allow the same name to be used for more than one class In this file you will learn how to create and use namespaces. + +## OOP Pill + +### Author comments + +In this pill I created three different classes inherited from the next one. The top one being abstract and the base one defining the methods indicated in the abstract taken from the interface. + +The idea behind is a theater system that register different plays for the next season and need certain info. If we instantiate the method welcome from the class StageSpectacles it will return a message indicating us to add more info which means we need to instantiate from the class Plays. If we call the same method in this class we will be able to enter the system. This is called method overloading. + +Also a property overriding is shown when the number of artists is below the indicated one. A message will be shown to update it and when the number meets the requirement it will allow us to continue. +