PHP OOP Project

Basic Simple Project By Me:

<?php

class Employee
{

    var $first;
    var $last;
    var $stat;
    var $uid;
    var $rate;
    var $hours;

    final public function __construct($f, $l, $st, $ui, $r, $ho)
    {
        $this->first = $f;
        $this->last = $l;
        $this->stat = $st;
        $this->uid = $ui;
        $this->rate = $r;
        $this->hours = $ho;
    }

    public function getALL()
    {
        echo "First Name:" . $this->first;
        echo "</br>";
        echo "Last Name:" . $this->last;
        echo "</br>";
        echo "Status:" . $this->stat;
        echo "</br>";
        echo "USerID:" . $this->uid;
        echo "</br>";
        echo "Pay Rate:$" . $this->rate;
        echo "</br>";
        echo "Housrs Worked:" . $this->hours;
        echo "</br>";
        echo "<b>Paycheck Amount:</b> $" . ($this->rate * $this->hours);
        echo "</br>";
        echo "</br>";

    }

}

class People extends Employee
{

}

$e = new People('JAddian', 'Forte', 'Manager', '521', '19', '40');
$e->getALL();

$e = new People('Victor', 'Davis', 'Assistant Manager', '231', '15', '33');
$e->getALL();

$e = new People('John', 'Clark', 'Worker', '687', '12', '26');
$e->getALL();

?>

By Others:
From OOP Fundamentals udemy Video project:

<?php

class Employee
{

    const MANAGER = 'MANAGER';
    const ASSISTANT_MANAGER='Assistant Manager';
    const WORKER='Worker';

//attributes
    protected $first;
    protected $last;
    protected $stat;
    protected $uid;
    protected $rate;
    protected $hours;

//class constructor
    final public function __construct($f, $l, $st, $ui, $r, $ho)
    {
        $this->first = $f;
        $this->last = $l;
        $this->stat = $st;
        $this->uid = $ui;
        $this->rate = $r;
        $this->hours = $ho;
    }

//function
    public function getALL()
    {
        echo "First Name:" . $this->first;
        echo "</br>";
        echo "Last Name:" . $this->last;
        echo "</br>";
        echo "Status:" . $this->stat;
        echo "</br>";
        echo "USerID:" . $this->uid;
        echo "</br>";
        echo "Pay Rate:$" . $this->rate;
        echo "</br>";
        echo "Housrs Worked:" . $this->hours;
        echo "</br>";
        echo "<b>Paycheck Amount:</b> $" . ($this->rate * $this->hours);
        echo "</br>";
        echo "</br>";
    }
} //end of employee class

class People extends Employee
{

}

$employee1 = new People('JAddian', 'Forte', People::MANAGER, '521', '19', '40');
$employee1->getALL();

$employee2 = new People('Victor', 'Davis', People::ASSISTANT_MANAGER, '231', '15', '33');
$employee2->getALL();

$employee3 = new People('John', 'Clark', Employee::WORKER, '687', '12', '26');
$employee3->getALL();

?>

 

It would be a great help, if you support by sharing :)
Author: zakilive

Leave a Reply

Your email address will not be published. Required fields are marked *