Skip to content

Commit

Permalink
upload to github
Browse files Browse the repository at this point in the history
  • Loading branch information
wabualela committed Oct 29, 2019
0 parents commit 140123e
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 0 deletions.
41 changes: 41 additions & 0 deletions Bicycle.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?php
class Bicycle
{
var $brand;
var $model;
var $year;
var $description = "Used Bicycle";
var $weight_kg = 0.0;


function name()
{
return "{$this->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 = "<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;
28 changes: 28 additions & 0 deletions Customer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
include './Human.php';

class Customer extends Human
{ }

echo "<title>PHP OOP Sandbox </title>";
const BR = "<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;

19 changes: 19 additions & 0 deletions Human.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
class Human
{
var $first_name;
var $second_name;
var $birth_date = [];

function full_name()
{
return "{$this->frist_name} {$this->second_name}";
}

function age()
{

return "";
}
}

24 changes: 24 additions & 0 deletions Product.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
class Product
{ }
const BR = "<br>";
$tile = new Product;
$facade = new Product;
$classes = ['Product', 'Category', 'product'];

echo "<title>PHP OOP Sandbox </title>";
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;
}
}
4 changes: 4 additions & 0 deletions Student.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?php
class Student{

}
3 changes: 3 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php
echo "<title>PHP OOP Sandbox </title>";
echo "<h1> working </h1>";
15 changes: 15 additions & 0 deletions object_basic.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

class Product
{ }
$classes = get_declared_classes();
echo "Classes: " . implode(",<br> ", $classes) . "<br>";

$class_names = ['Product', 'Category', 'Project', 'product'];
foreach ($class_names as $class_name) {
if (class_exists($class_name)) {
echo "{$class_name} is declared class.<br>";
} else {
echo "{$class_name} is not declared class.<br>";
}
}

0 comments on commit 140123e

Please sign in to comment.