From 140123ee9d20fcadcea92dc2878c731948c42a8d Mon Sep 17 00:00:00 2001 From: wailabualela Date: Tue, 29 Oct 2019 15:48:18 +0200 Subject: [PATCH] upload to github --- Bicycle.php | 41 +++++++++++++++++++++++++++++++++++++++++ Customer.php | 28 ++++++++++++++++++++++++++++ Human.php | 19 +++++++++++++++++++ Product.php | 24 ++++++++++++++++++++++++ Student.php | 4 ++++ index.php | 3 +++ object_basic.php | 15 +++++++++++++++ 7 files changed, 134 insertions(+) create mode 100644 Bicycle.php create mode 100644 Customer.php create mode 100644 Human.php create mode 100644 Product.php create mode 100644 Student.php create mode 100644 index.php create mode 100644 object_basic.php diff --git a/Bicycle.php b/Bicycle.php new file mode 100644 index 0000000..d67aa99 --- /dev/null +++ b/Bicycle.php @@ -0,0 +1,41 @@ +brand}, {$this->model} ({$this->year})"; + } + + function weight_lbs() + { + return (floatval($this->weight_kg) * 2.2046226218) . " lbs"; + } + + function set_weight_lbs($value) + { + $this->weight_kg = floatval($value) / 2.2046226218; + } +} + +$bicycle = new Bicycle; + +$bicycle->brand = "new"; +$bicycle->model = "SDN"; +$bicycle->year = 2019; +$bicycle->weight_kg = 75; + +const BR = "
"; + +echo "Bicycle Name: {$bicycle->name()}" . BR; +echo "Bicycle Weight (lbs): {$bicycle->weight_lbs()}" . BR; +echo "Bicycle Weight (kg): " . ($bicycle->weight_lbs() / 2.2046226218) . BR; +echo "Bicycle set Weight to 200 lbs: " . ($bicycle->set_weight_lbs(200)) . BR; +echo "Bicycle Weight (lbs): {$bicycle->weight_lbs()}" . BR; +echo "Bicycle Weight (kg): {$bicycle->weight_kg}" . BR; diff --git a/Customer.php b/Customer.php new file mode 100644 index 0000000..03ac184 --- /dev/null +++ b/Customer.php @@ -0,0 +1,28 @@ +PHP OOP Sandbox "; +const BR = "
"; + + + + + + +$kamal = new Customer; +$kamal->frist_name = "Kamal"; +$kamal->second_name = "Farouk"; +$kamal->birth_date['d'] = 23; +$kamal->birth_date['m'] = 7; +$kamal->birth_date['y'] = 1992; + +echo $kamal->full_name() . BR; + +// $omer = new Customer; +// $omer->frist_name = "Omer"; +// $omer->second_name = "Ali"; +// echo $omer->full_name() . BR; + diff --git a/Human.php b/Human.php new file mode 100644 index 0000000..6bcc69b --- /dev/null +++ b/Human.php @@ -0,0 +1,19 @@ +frist_name} {$this->second_name}"; + } + + function age() + { + + return ""; + } +} + diff --git a/Product.php b/Product.php new file mode 100644 index 0000000..c3f1267 --- /dev/null +++ b/Product.php @@ -0,0 +1,24 @@ +"; +$tile = new Product; +$facade = new Product; +$classes = ['Product', 'Category', 'product']; + +echo "PHP OOP Sandbox "; +echo get_class($tile) .BR; + +foreach ($classes as $class) { + if (is_a($tile, $class)) { + echo "Tile is a {$class} instance" .BR; + } else { + echo "Tile is not a {$class} instance" .BR; + } + + if (is_a($facade, $class)) { + echo "Facade is a {$class} instance" .BR; + } else { + echo "Facade is not a {$class} instance" .BR; + } +} diff --git a/Student.php b/Student.php new file mode 100644 index 0000000..750c659 --- /dev/null +++ b/Student.php @@ -0,0 +1,4 @@ +PHP OOP Sandbox "; +echo "

working

"; diff --git a/object_basic.php b/object_basic.php new file mode 100644 index 0000000..d897b87 --- /dev/null +++ b/object_basic.php @@ -0,0 +1,15 @@ + ", $classes) . "
"; + +$class_names = ['Product', 'Category', 'Project', 'product']; +foreach ($class_names as $class_name) { + if (class_exists($class_name)) { + echo "{$class_name} is declared class.
"; + } else { + echo "{$class_name} is not declared class.
"; + } +}