class declarations and member function definitions for an employee menu driven program | PHP - IProgramX


Q:Write class declarations and member function definitions for an employee(code, name, designation). Derive emp_account(account_no, joining_date) from employee and emp_sal(basic_pay, earnings, deduction) from emp_account. Write a menu driven program 
        a) To build a master table 
        b) To sort all entries 
        c) To search an entry 
        d) Display salary


HTML File

<html>
<head><title>Exercise 4 Set A 2</title></head>


<body bgcolor="fuschia">

<u><center><h1>Employee Details.</h1></center></u>

<br/>
<hr>
<FORM action=a4a2.php method=post>
<h3><input type='radio' name='op' value='1'> Build and Display master table.<br/>
<input type='radio' name='op' value='2'> Sort all entries.<br/>
<input type='radio' name='op' value='3'> Search an entry. <br/>
<input type='radio' name='op' value='4'> Display salary.  <br/><h3>
<br/>
<br/>

<pre>
        <input type='submit' name='submit' value='QUERRY.'>

</pre>
</form>

</form>
</body>
</html>

HP Function:
NOTE: PHP function is saved as "a4a2.php"


<html>
<body bgcolor='fuschia'>
<br/>

<?
$op=$_POST['op'];

Echo"EMPLOYEE DETAIL:"."<BR>";
class emp
{
        function code($a)
        {
                echo"Code=$a"."<BR>";
        }

        function n($b)
        {
                echo"Name= $b"."<BR>";
        }

        function destination($c)
        {
                echo"Destination=$c"."<BR";
        }
}

class emp_account extends emp
{
        function a_no($d)
        {
        echo"A_no=$d"."<BR>";
        }

        function joindate($e)
        {
                echo"Join date = $e"."<BR>";
        }
}
class emp_sal extends emp_account
{
        function basic_pay($f)
        {
                echo"Basic pay=$f"."<BR>";
        }

        function ear($h)
        {
                echo"<BR>"."Earninigs=$h"."<Br>";
        }

        function deduction($g)
        {
                echo"Deduction=$g";
        }
}

$c1=new emp();
$c1->code('54017');
$c1->n('SAGAR');
$c1->destination('pune');
$c2=new emp_account();
$c2->a_no(1);
$c2->joindate('12-06-2009');
$c3=new emp_sal();
$c3->basic_pay(300);
$c3->ear(5000);
$c3->deduction(100);

switch($op)
{
case 1 :echo" <table align='center' border =2  bgcolor='yellow'>";
        echo"<tr><th>CODE</th>";
                echo"<th>NAME</th>";
                echo"<th>DESIGNATION</th>";
                echo"<th>A_no</th>";
                echo"<th>Join_Date</th>";
                echo"<th>Basic_pay</th>";
                echo"<th>earinng</th>";
                echo"<th>deduction</th>";
                        echo"<tr>";

                        echo"<td>$a</td>";
                        echo"<td>$b</td>";
                         echo"<td>$c</td>";
                        echo"<td>$d</td>";
                         echo"<td>$e</td>";
                        echo"<td>$f</td>";
                         echo"<td>$g</td>";
                        echo"<td>$c3->deduction($h)</td>";

                        echo"</tr>";


                echo"</table>";
           break;

case '2':
           break;

case '3':
           break;

case '4':
           break;


}

Post a Comment

1 Comments