Symbianize Forum

Most of our features and services are available only to members, so we encourage you to login or register a new account. Registration is free, fast and simple. You only need to provide a valid email. Being a member you'll gain access to all member forums and features, post a message to ask question or provide answer, and share or find resources related to mobile phones, tablets, computers, game consoles, and multimedia.

All that and more, so what are you waiting for, click the register button and join us now! Ito ang website na ginawa ng pinoy para sa pinoy!

[oop php] need assistance

JosefGrafixStudio

 
Apprentice
Advanced Member
Messages
69
Reaction score
1
Points
28
Power Stone
Reality Stone
Soul Stone
Time Stone
Good Pm! mga sir, madam! na magagaling sa PHP OOP hiinhingi ko po yung assistance niyo sa activity namain kasi nalilibog ako sa instruction po namin
naway pagbigyan niyo ako hehe :praise: :lol:

eto po yung instruction:

View attachment 304215

eto po dapat yung output:

View attachment 304216


eto po yung ginawa ko syempre baghan lang ako kaya pagpasinsyahan niyo na code hehe..

index.php

Code:
<!DOCTYPE html>
<html>
<head>
	<title>Activity 5</title>
</head>
<body>


<?php 

	session_start();
	include('Class/class.php');

 ?>

 <form method="POST">
 		Enter Employee ID: <input type="number" name="id"><input type="submit" name="submit" value="Search">
 </form>


<?php 
		 
	$var = new Repository();

	$id = $_POST['id'];

 
if(isset($_POST['submit'])){
	 if ($id = 1) {
    	$var->find($id);
    $accountant = new Accountant(1,'Accountant 1','Accounting', 15000);
	$manager = new Manager(1,'Manager 1','Managering', 15000);
	$securityGuard = new SecurityGuard(1,'SecurityGuard 1','SecurityGuarding', 15000);
    $janitor = new Janitor(1,'Janitor 1','Janitoring', 15000);

	$manager->displayInfo();
	$accountant->displayInfo();
	$janitor->displayInfo();
	$securityGuard->displayInfo();

    }else if ($id == 2) {
    	$var->find($id);
    $accountant = new Accountant(2,'Accountant 2','Accounting', 12341);
	$manager = new Manager(2,'Manager 2','Managering', 12341);
	$securityGuard = new SecurityGuard(2,'SecurityGuard 2','SecurityGuarding', 12341);
    $janitor = new Janitor(2,'Janitor 2','Janitoring', 12341);

	$manager->displayInfo();
	$accountant->displayInfo();
	$janitor->displayInfo();
	$securityGuard->displayInfo();
    }else if ($id == 3) {
    	$var->find($id);
   	$accountant = new Accountant(3,'Accountant 3','Accounting', 55123);
	$manager = new Manager(3,'Manager 3','Managering', 55123);
	$securityGuard = new SecurityGuard(3,'SecurityGuard 3','SecurityGuarding', 55123);
    $janitor = new Janitor(3,'Janitor 3','Janitoring', 55123);

	$manager->displayInfo();
	$accountant->displayInfo();
	$janitor->displayInfo();
	$securityGuard->displayInfo();
    }else {
    	$var->find($id);
    $accountant = new Accountant(4,'Accountant 4','Accounting', 12524);
	$manager = new Manager(4,'Manager 4','Managering', 12524);
	$securityGuard = new SecurityGuard(4,'SecurityGuard 4','SecurityGuarding', 12524);
    $janitor = new Janitor(4,'Janitor 4','Janitoring', 12524);

	$manager->displayInfo();
	$accountant->displayInfo();
	$janitor->displayInfo();
	$securityGuard->displayInfo();
    }
}
    
 

 ?>


</body>
</html>


class.php

Code:
<?php 

		
		Class Employee{

				public $name = '', $id = 0, $salary = 0, $position = '', $department = '';

			 function __construct($id = 0, $name = '', $department = '', $salary = 0){
				$this->id = $id;
				$this->name = $name; 
				$this->department = $department;
				$this->salary = $salary;
				
			}

			public function setName($name = 0){$this->name = $name;}
			public function getName(){return $this->name;}

			public function setID($id = 0){$this->id = $id;}
			public function getID(){return $this->id;}

			public function setSalary($salary = 0){$this->salary = $salary;}
			public function getSalary(){return $this->salary;}

			public function setDepartment($department = ''){$this->department = $department;}
			public function getDepartment(){return $this->department;}

			public function displayInfo(){
				echo "<br>" . "ID: " . $this->id . "<br>";
				echo "Name: " . $this->name . "<br>";
				echo "Position: " . $this->position . "<br>";
				echo "Department: " . $this->department . "<br>";
				echo "Salary: " . $this->salary . "<br>" . "<br>";
			}

		}

		Class Accountant extends Employee{
			public function __construct($id = 0, $name = '',$department = '', $salary = 0){
				parent::__construct($id,$name,$department,$salary);
				$this->position = 'Accountant';
			}
		}

		Class Manager extends Employee{
			public function __construct($id = 0, $name = '',$department = '', $salary = 0){
				parent::__construct($id,$name,$department,$salary);
				$this->position = 'Manager';
			}
		}

		Class SecurityGuard extends Employee{
			public function __construct($id = 0, $name = '',$department = '', $salary = 0){
				parent::__construct($id,$name,$department,$salary);
				$this->position = 'SecurityGuard';
			}
		}

		Class Janitor extends Employee{
			public function __construct($id = 0, $name = '',$department = '', $salary = 0){
				parent::__construct($id,$name,$department,$salary);
				$this->position = 'Janitor';
			}
		}


		Class Repository {

				var $models;

				public function find($id){
					if($id == 1){
				echo "<br>" . "ID: " . Repository::$id . "<br>";
				echo "Name: " . Repository::$name . "<br>";
				echo "Position: " . Repository::$position . "<br>";
				echo "Department: " . Repository::$department . "<br>";
				echo "Salary: " . Repository::$salary . "<br>" . "<br>";
					}else  if ($id == 2) {
				echo "<br>" . "ID: " . Repository::$id . "<br>";
				echo "Name: " . Repository::$name . "<br>";
				echo "Position: " . Repository::$position . "<br>";
				echo "Department: " . Repository::$department . "<br>";
				echo "Salary: " . Repository::$salary . "<br>" . "<br>";
					}else  if ($id == 3) {
				echo "<br>" . "ID: " . Repository::$id . "<br>";
				echo "Name: " . Repository::$name . "<br>";
				echo "Position: " . Repository::$position . "<br>";
				echo "Department: " . Repository::$department . "<br>";
				echo "Salary: " . Repository::$salary . "<br>" . "<br>";
					}else{
				echo "<br>" . "ID: " . Repository::$id . "<br>";
				echo "Name: " . Repository::$name . "<br>";
				echo "Position: " . Repository::$position . "<br>";
				echo "Department: " . Repository::$department . "<br>";
				echo "Salary: " . Repository::$salary . "<br>" . "<br>";
					}

				}

		}

		Class AccountantRepository extends Repository{
			
			 public function __construct($name = '', $id = 0, $salary = 0, $department = '')
			{ 
				$this->models == array(
					new Acountant(1,'Accountant 1','Accounting', 15000),
					new Acountant(2,'Accountant 2','Accounting', 12341),
					new Acountant(3,'Accountant 3','Accounting', 55123),
					new Acountant(4,'Accountant 4','Accounting', 51343),
					new Acountant(5,'Accountant 5','Accounting', 12524));	
			}			
		}

 
 ?>

salamat po sa lahat ng sasagot :) naway pagpalain pa kayo :) TIA!
 

Attachments

  • act5-instruction.png
    act5-instruction.png
    41.5 KB · Views: 23
  • act5-output.png
    act5-output.png
    16.7 KB · Views: 14
Good Pm! mga sir, madam! na magagaling sa PHP OOP hiinhingi ko po yung assistance niyo sa activity namain kasi nalilibog ako sa instruction po namin
naway pagbigyan niyo ako hehe :praise: :lol:

eto po yung instruction:

View attachment 1183957

eto po dapat yung output:

View attachment 1183958


eto po yung ginawa ko syempre baghan lang ako kaya pagpasinsyahan niyo na code hehe..

index.php

Code:
<!DOCTYPE html>
<html>
<head>
	<title>Activity 5</title>
</head>
<body>


<?php 

	session_start();
	include('Class/class.php');

 ?>

 <form method="POST">
 		Enter Employee ID: <input type="number" name="id"><input type="submit" name="submit" value="Search">
 </form>


<?php 
		 
	$var = new Repository();

	$id = $_POST['id'];

 
if(isset($_POST['submit'])){
	 if ($id = 1) {
    	$var->find($id);
    $accountant = new Accountant(1,'Accountant 1','Accounting', 15000);
	$manager = new Manager(1,'Manager 1','Managering', 15000);
	$securityGuard = new SecurityGuard(1,'SecurityGuard 1','SecurityGuarding', 15000);
    $janitor = new Janitor(1,'Janitor 1','Janitoring', 15000);

	$manager->displayInfo();
	$accountant->displayInfo();
	$janitor->displayInfo();
	$securityGuard->displayInfo();

    }else if ($id == 2) {
    	$var->find($id);
    $accountant = new Accountant(2,'Accountant 2','Accounting', 12341);
	$manager = new Manager(2,'Manager 2','Managering', 12341);
	$securityGuard = new SecurityGuard(2,'SecurityGuard 2','SecurityGuarding', 12341);
    $janitor = new Janitor(2,'Janitor 2','Janitoring', 12341);

	$manager->displayInfo();
	$accountant->displayInfo();
	$janitor->displayInfo();
	$securityGuard->displayInfo();
    }else if ($id == 3) {
    	$var->find($id);
   	$accountant = new Accountant(3,'Accountant 3','Accounting', 55123);
	$manager = new Manager(3,'Manager 3','Managering', 55123);
	$securityGuard = new SecurityGuard(3,'SecurityGuard 3','SecurityGuarding', 55123);
    $janitor = new Janitor(3,'Janitor 3','Janitoring', 55123);

	$manager->displayInfo();
	$accountant->displayInfo();
	$janitor->displayInfo();
	$securityGuard->displayInfo();
    }else {
    	$var->find($id);
    $accountant = new Accountant(4,'Accountant 4','Accounting', 12524);
	$manager = new Manager(4,'Manager 4','Managering', 12524);
	$securityGuard = new SecurityGuard(4,'SecurityGuard 4','SecurityGuarding', 12524);
    $janitor = new Janitor(4,'Janitor 4','Janitoring', 12524);

	$manager->displayInfo();
	$accountant->displayInfo();
	$janitor->displayInfo();
	$securityGuard->displayInfo();
    }
}
    
 

 ?>


</body>
</html>


class.php

Code:
<?php 

		
		Class Employee{

				public $name = '', $id = 0, $salary = 0, $position = '', $department = '';

			 function __construct($id = 0, $name = '', $department = '', $salary = 0){
				$this->id = $id;
				$this->name = $name; 
				$this->department = $department;
				$this->salary = $salary;
				
			}

			public function setName($name = 0){$this->name = $name;}
			public function getName(){return $this->name;}

			public function setID($id = 0){$this->id = $id;}
			public function getID(){return $this->id;}

			public function setSalary($salary = 0){$this->salary = $salary;}
			public function getSalary(){return $this->salary;}

			public function setDepartment($department = ''){$this->department = $department;}
			public function getDepartment(){return $this->department;}

			public function displayInfo(){
				echo "<br>" . "ID: " . $this->id . "<br>";
				echo "Name: " . $this->name . "<br>";
				echo "Position: " . $this->position . "<br>";
				echo "Department: " . $this->department . "<br>";
				echo "Salary: " . $this->salary . "<br>" . "<br>";
			}

		}

		Class Accountant extends Employee{
			public function __construct($id = 0, $name = '',$department = '', $salary = 0){
				parent::__construct($id,$name,$department,$salary);
				$this->position = 'Accountant';
			}
		}

		Class Manager extends Employee{
			public function __construct($id = 0, $name = '',$department = '', $salary = 0){
				parent::__construct($id,$name,$department,$salary);
				$this->position = 'Manager';
			}
		}

		Class SecurityGuard extends Employee{
			public function __construct($id = 0, $name = '',$department = '', $salary = 0){
				parent::__construct($id,$name,$department,$salary);
				$this->position = 'SecurityGuard';
			}
		}

		Class Janitor extends Employee{
			public function __construct($id = 0, $name = '',$department = '', $salary = 0){
				parent::__construct($id,$name,$department,$salary);
				$this->position = 'Janitor';
			}
		}


		Class Repository {

				var $models;

				public function find($id){
					if($id == 1){
				echo "<br>" . "ID: " . Repository::$id . "<br>";
				echo "Name: " . Repository::$name . "<br>";
				echo "Position: " . Repository::$position . "<br>";
				echo "Department: " . Repository::$department . "<br>";
				echo "Salary: " . Repository::$salary . "<br>" . "<br>";
					}else  if ($id == 2) {
				echo "<br>" . "ID: " . Repository::$id . "<br>";
				echo "Name: " . Repository::$name . "<br>";
				echo "Position: " . Repository::$position . "<br>";
				echo "Department: " . Repository::$department . "<br>";
				echo "Salary: " . Repository::$salary . "<br>" . "<br>";
					}else  if ($id == 3) {
				echo "<br>" . "ID: " . Repository::$id . "<br>";
				echo "Name: " . Repository::$name . "<br>";
				echo "Position: " . Repository::$position . "<br>";
				echo "Department: " . Repository::$department . "<br>";
				echo "Salary: " . Repository::$salary . "<br>" . "<br>";
					}else{
				echo "<br>" . "ID: " . Repository::$id . "<br>";
				echo "Name: " . Repository::$name . "<br>";
				echo "Position: " . Repository::$position . "<br>";
				echo "Department: " . Repository::$department . "<br>";
				echo "Salary: " . Repository::$salary . "<br>" . "<br>";
					}

				}

		}

		Class AccountantRepository extends Repository{
			
			 public function __construct($name = '', $id = 0, $salary = 0, $department = '')
			{ 
				$this->models == array(
					new Acountant(1,'Accountant 1','Accounting', 15000),
					new Acountant(2,'Accountant 2','Accounting', 12341),
					new Acountant(3,'Accountant 3','Accounting', 55123),
					new Acountant(4,'Accountant 4','Accounting', 51343),
					new Acountant(5,'Accountant 5','Accounting', 12524));	
			}			
		}

 
 ?>

salamat po sa lahat ng sasagot :) naway pagpalain pa kayo :) TIA!



up ko lang badly needed ...
 
para ka namang naka JAVA nyan.. eh pero ganda ng approach mo

- - - Updated - - -

tama naman yung ginawa mo.. involve ba dito yung database?
 
para ka namang naka JAVA nyan.. eh pero ganda ng approach mo

- - - Updated - - -

tama naman yung ginawa mo.. involve ba dito yung database?

no database po sir eh wala si instruction hmmm
 
Back
Top Bottom