diff --git a/Documents/OOP.pdf b/Documents/OOP.pdf new file mode 100644 index 0000000..922fec1 Binary files /dev/null and b/Documents/OOP.pdf differ diff --git a/Documents/Scheme class.pdf b/Documents/Scheme class.pdf new file mode 100644 index 0000000..11984de Binary files /dev/null and b/Documents/Scheme class.pdf differ 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 diff --git a/Pill/01-base-class.php b/Pill/01-base-class.php new file mode 100644 index 0000000..fd2ca40 --- /dev/null +++ b/Pill/01-base-class.php @@ -0,0 +1,60 @@ +name = $name; + $this->color = $color; + $this->taste = $taste; +} +//destruct + +public function __destruct() +{ + $this->peel; +} + +public function getFruitDetails() { + return "

Fruit

+ Name: {$this->name}
+ Color: {$this->color}
+ Type: {$this->taste}
"; +} + +//methods + + public function Feed() { + + echo 'I am feeding'; +} + + public function Hydrate() { + + echo 'I am hydrating'; + } + + public function Regular() { + + echo 'I regulate intestinal transit'; + } + + +} + + + + + +?> \ No newline at end of file diff --git a/Pill/02-inherit-class.php b/Pill/02-inherit-class.php new file mode 100644 index 0000000..99649da --- /dev/null +++ b/Pill/02-inherit-class.php @@ -0,0 +1,44 @@ +origin = $origin; + + } + + public function getOrigin() + { + return $this->origin; + } + + public function getVitamin() { + + echo 'I have vitamin C'; +} + + public function getFruitDetails() { + return "

Fruit

+ Name: {$this->name}
+ Color: {$this->color}
+ Type: {$this->taste}
+ Origin: {$this->origin}"; + } +} + + + + +?> \ No newline at end of file diff --git a/Pill/03-abstract-class.php b/Pill/03-abstract-class.php new file mode 100644 index 0000000..644a804 --- /dev/null +++ b/Pill/03-abstract-class.php @@ -0,0 +1,26 @@ + +getUses(); + } + +} + +class Lemon extends Citric { + public function getUses(){ + return " "; + } + + public function values($uses){ + return "Lemon is useful for " . $uses; + } +} + +?> diff --git a/Pill/04-interfaces.php b/Pill/04-interfaces.php new file mode 100644 index 0000000..17604ac --- /dev/null +++ b/Pill/04-interfaces.php @@ -0,0 +1,35 @@ + \ No newline at end of file diff --git a/Pill/index.php b/Pill/index.php new file mode 100644 index 0000000..83301be --- /dev/null +++ b/Pill/index.php @@ -0,0 +1,29 @@ +getFruitDetails(); +echo "
"; +echo $myFruit->Feed(); +echo "
"; +echo $myFruit->Hydrate(); +echo "
"; +echo $myFruit->Regular(); +echo "
"; +$Kiwi = new Kiwi ('kiwi', 'green', 'acid', 'china'); +echo $Kiwi->getFruitDetails(); +echo "

"; +echo $Kiwi->getVitamin(); +echo "


"; + +$Lemons = new Lemon; + +$Lemons->Uses(); +echo $Lemons->values("flu"); + + + +?> \ No newline at end of file diff --git a/README.md b/README.md index e644e6a..ac57f6e 100644 --- a/README.md +++ b/README.md @@ -2,18 +2,16 @@ # Assembler School: OOP Basics with PHP -In this project you will learn the basics of OOP using mobile devices as a reference. In the _"Project files"_ section you will find a description of the content to be displayed in each file. +In this project you will learn the basics of OOP using fruits as a reference. In the _"Project files"_ section you will find a description of the content to be displayed in each file. ## Table of contents - [Table of contents](#table-of-contents) -- [Getting Started](#getting-started) - [Dependencies](#dependencies) - [Tools](#tools) - [OOP Introduction](#oop-introduction) - [Project files](#project-files) -## Getting Started ### The repo @@ -23,10 +21,11 @@ First, you will need to clone the repo: $ git clone https://github.com/assembler-school/oop-basics.git ``` -### Presentation material - -- [Slides](https://docs.google.com/presentation/d/1cZxutGPDqUGsLWLVen_ATjd7dEkeoPS_v_fy1y0C5Co/edit?usp=sharing) +### Wireframes +- Documents folder: + - OOP: Document with basics concepts + - Scheme class: Document with a wireframe of the pill. ## Dependencies Before we can get started you will need to make sure that all the necessary dependencies are installed in your system. @@ -45,19 +44,6 @@ $ php -version In the event that you prefer to use a tool that installs everything you need to configure and run a PHP server, we recommend using [XAMPP](https://www.apachefriends.org/es/download.html) -### XAMPP - -XAMPP is a completely free and easy to install Apache distribution that contains MariaDB, PHP, and Perl. The XAMPP installation package has been designed to be incredibly easy to install and use. - -xampp homepage - -You have to go to the [download page](https://www.apachefriends.org/es/download.html) and it will automatically recommend installing the latest version available. - -xampp download - -Once downloaded and installed, in the case that the Windows operating system you will see the following screen, in which you will only have to start the Apache service. - -xampp app ## OOP Introduction @@ -65,72 +51,24 @@ Object-oriented programming (OOP) is a programming paradigm based on the concept ## Project files -### [01 - Classes](./01-classes.php) - -The OOP paradigm encapsulates concepts of the real world in what is called as Classes which create Objects. In this file you will learn how to create a class and instanciate it. - -### [02 - Properties](02-properties.php) - -Class member variables are called properties. In this file, you will learn how to add properties to a class and get them when the class is instantiated. - -### [03 - Methods](03-methods.php) - -Properties define the characteristics of an object and the methods (functions in a class are called methods) which define the behavior of the Class. In this file you will learn how to create methods inside a class. - -### [04 - Getters](04-getters.php) - -The get method returns the attribute value, usually there is a get method for each attribute of the class. In this file you will learn how to create **getter** methods. - -### [05 - Setters](05-setters.php) +### [01 - Base Class](./Pill/01-base-class.php01-base-class.php) -The set method sets the attribute value, usually there is a get method for each attribute of the class. In this file you will learn how to create **setter** methods. +The OOP paradigm encapsulates concepts of the real world in what is called as Classes which create Objects. In this file you will learn how to create a class and implement methods. -### [06 - Constructors](06-constructors.php) - -A constructor allows you to initialize an object's properties upon creation of the object. In this file you will learn how to create the constructor method. - -### [07 - Inheritance problem](07-inheritance-problem.php) - -There are several disadvantages of not applying inheritance in our code. In this file you will lean what's the problem if you don't apply any inheritance in your code. - -### [08 - Inheritance soluction](08-inheritance-solution.php) +### [02 - Inherit class](./Pill/02-inherit-class.php) The child class will inherit all the public and protected properties and methods from the parent class. In addition, it can have its own properties and methods. In this file you will learn how to apply the inheritance in your code. -### [09 - Public, private & protected](09-public-private-protected.php) - -Properties and methods can have access modifiers which control where they can be accessed. In this file you will learn le three access modifiers. - -### [10 - Static](10-static.php) - -Static properties and methods can be called directly - without creating an instance of the class first. In this file you will learn how to use static properties and methods. - -### [11 - Const](11-const.php) - -Constants cannot be changed once it is declared. Class constants can be useful if you need to define some constant data within a class. In this file you will learn how to create constants within a class. - -### [12 - Abstract classes](12-abstract-classes.php) +### [03 - Abstract class](./Pill/03-abstract-class.php) Abstract classes and methods are when the parent class has a named method, but need its child class(es) to fill out the tasks. In this file you will learn how to create and use abstract classes. -### [13 - Interfaces](13-interfaces.php) +### [04 - Interfaces](./Pill/04-interface.php) Interfaces allow you to specify what methods a class should implement. Interfaces make it easy to use a variety of different classes in the same way. When one or more classes use the same interface, it is referred to as "polymorphism". In this file you will learn how to create and extend interfaces. -### [14 - Overriding](14-overriding.php) - -In function overriding, both parent and child classes should have same function name with and number of arguments. In this file you will learn how to implement overriding. - -### [15 - Overloading](15-overloading.php) - -Function overloading contains same function name and that function preforms different task according to number of arguments. In this file you will learn how to implement overloading. - -### [16 - Namespaces](16-namespaces.php) - -Namespaces are qualifiers that solve two different problems: +### [Index](./Pill/index.php) -1. They allow for better organization by grouping classes that work together to perform a task -2. They allow the same name to be used for more than one class +In this document you will find all the instances of the pill. -In this file you will learn how to create and use namespaces. diff --git a/assets/img/xampp-app.png b/assets/img/xampp-app.png deleted file mode 100644 index 144ec73..0000000 Binary files a/assets/img/xampp-app.png and /dev/null differ diff --git a/assets/img/xampp-download.png b/assets/img/xampp-download.png deleted file mode 100644 index 0e06cbb..0000000 Binary files a/assets/img/xampp-download.png and /dev/null differ diff --git a/assets/img/xampp-homepage.png b/assets/img/xampp-homepage.png deleted file mode 100644 index c33ea9f..0000000 Binary files a/assets/img/xampp-homepage.png and /dev/null differ