1. Write class declarations and member function definitions
for following employee(code, name, designation). Design derived classes as
emp_account(account_no, joining_date) from employee and emp_sal(basic_pay,
earnings, deduction) from emp_account ,Write a PHP Script to create 5 objects
(pass details using parameterized constructor) and Display details of Employees
who having Maximum and Minimum Salary.
<?php
class Employee
{
public $eid,$ename,$edesg;
function __construct($a,$b,$c)
{
$this->eid=$a;
$this->ename=$b;
$this->edesg=$c;
}
public function getdata()
{
return $this->sal;
}
public function display()
{
echo $this->eid."</br>";
echo $this->ename."</br>";
echo $this->edesg."</br>";
//echo $this->ename."</br>";
}
}
class Emp_account extends Employee
{
public $ac_no,$jdate;
public static $total1=0;
function __construct($a,$b,$c,$d,$e)
{
parent::__construct($a,$b,$c);
$this->ac_no=$d;
$this->jdate=$e;
}
}
class Emp_sal extends Emp_account
{
public $b_pay,$er,$dud;
//public static $total1=0;
function __construct($a,$b,$c,$d,$e,$f,$g,$h)
{
parent::__construct($a,$b,$c,$d,$e);
$this->b_pay=$f;
$this->er=$g;
$this->dud=$h;
}
public function max($ob)
{
//$sal=$this->getdata();
$total=$this->b_pay+$this->er;
$total=$total-$this->dud;
if($total>self::$total1)
{
self::$total1=$total;
return $this;
}
else
{
return $ob;
}
}
public function min($ob)
{
//$sal=$this->getdata();
$total=$this->b_pay+$this->er;
$total=$total-$this->dud;
if($total<self::$total1)
{
self::$total1=$total;
return $this;
}
else
{
return $ob;
}
}
public function display()
{
// parent::display();
echo $this->ename;
//echo self::$total1;
}
}
$ob=new Emp_sal(0,"ABC","",0,"",0,0,0);
$temp=new Emp_sal(0,"ABC","",0,"",0,0,0);
$ob1=new Emp_sal(1,"ramdas","HOD",1234,"21/3/2015",28000,2000,500);
$ob=$ob1->max($ob);
$temp=$ob1->min($temp);
$ob2=new Emp_sal(1,"ramdas1","HOD",1234,"21/3/2015",48000,2000,500);
$ob=$ob2->max($ob);
$temp=$ob2->min($temp);
$ob3=new Emp_sal(1,"ramdas2","HOD",1234,"21/3/2015",58000,2000,500);
$ob=$ob3->max($ob);
$temp=$ob3->min($temp);
$ob4=new Emp_sal(1,"ramdas3","HOD",1234,"21/3/2015",8000,2000,500);
$ob=$ob4->max($ob);
$temp=$ob4->min($temp);
$ob5=new Emp_sal(1,"ramdas4","HOD",1234,"21/3/2015",7000,2000,500);
$ob=$ob5->max($ob);
$temp=$ob5->min($temp);
$ob->display();
$temp->display();
?>
hello sir this code does not display the information of employee
ReplyDelete.
Sir this code is wrong i will change that code because u are not use array of object
ReplyDeletePrashant, again you are doing same mistake. Read program carefully. it is clearly mentioned that Write a PHP Script to create 5 objects.
DeleteI recommend u to Join NR Classes
Thanks Sir....
DeleteSir the code is not displaying
ReplyDeleteSir, this code is giving wrong output. It is not considering first object value in both max and min functions. Even if first total value is considered max or min it is neglecting this value. Can you please rectify this logical error?
ReplyDeletesame here
ReplyDeleteAdvance Wed Technology All code Send in Email
ReplyDeleteatulavaghade2116@gmail.com