Skip to content

Commit 6d4e241

Browse files
committed
Resolving conflicts
2 parents 6adada9 + 341bc06 commit 6d4e241

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+320
-6719
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?php
2+
//Client.php
3+
function __autoload($class_name) {
4+
// echo $class_name."<br />";
5+
include $class_name . '.php';
6+
}
7+
8+
class Client {
9+
//For direct instantiation
10+
private $fly1;
11+
12+
private $fly2;
13+
14+
//For cloning
15+
private $c1Fly;
16+
17+
private $c2Fly;
18+
19+
private $updatedCloneFly;
20+
21+
public function __construct() {
22+
//Instantiate
23+
$this->fly1=new MaleProto();
24+
$this->fly2=new FemaleProto();
25+
//Clone
26+
$this->c1Fly = clone $this->fly1;
27+
$this->c2Fly = clone $this->fly2;
28+
$this->updatedCloneFly = clone $this->fly2;
29+
//update clones
30+
$this->c1Fly->mated="true";
31+
$this->c2Fly->fecundity="186";
32+
$this->updatedCloneFly->eyeColor="purple";
33+
$this->updatedCloneFly->wingBeat="220";
34+
$this->updatedCloneFly->unitEyes="750";
35+
$this->updatedCloneFly->fecundity="92";
36+
//Send through type hinting method
37+
$this->showFly($this->c1Fly);
38+
$this->showFly($this->c2Fly);
39+
$this->showFly($this->updatedCloneFly);
40+
}
41+
42+
private function showFly(IPrototype $fly) {
43+
echo "Eye color: " . $fly->eyeColor . "<br/>";
44+
echo "Wing Beats/second: " . $fly->wingBeat . "<br/>";
45+
echo "Eye units: " . $fly->unitEyes . "<br/>";
46+
$genderNow=$fly::gender;
47+
echo "Gender: " . $genderNow . "<br/>";
48+
if($genderNow=="FEMALE") {
49+
echo "Number of eggs: " . $fly->fecundity . "<p/>";
50+
} else {
51+
echo "Mated: " . $fly->mated . "<p/>";
52+
}
53+
}
54+
}
55+
56+
$worker=new Client();
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
//FemaleProto.php
3+
include_once('IPrototype.php');
4+
5+
class FemaleProto extends IPrototype {
6+
7+
const gender="FEMALE";
8+
9+
public $fecundity;
10+
11+
public function __construct() {
12+
$this->eyeColor="red";
13+
$this->wingBeat="220";
14+
$this->unitEyes="760 ";
15+
}
16+
17+
function __clone(){}
18+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
//IPrototype.php
4+
abstract class IPrototype {
5+
6+
public $eyeColor;
7+
8+
public $wingBeat;
9+
10+
public $unitEyes;
11+
12+
abstract function __clone();
13+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
//MaleProto.php
4+
include_once('IPrototype.php');
5+
6+
class MaleProto extends IPrototype {
7+
8+
const gender="MALE";
9+
10+
public $mated;
11+
12+
public function __construct() {
13+
$this->eyeColor="red";
14+
$this->wingBeat="220";
15+
$this->unitEyes="760 ";
16+
}
17+
18+
function __clone(){}
19+
20+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
//Client.php
3+
function __autoload($class_name) {
4+
include $class_name . '.php';
5+
}
6+
7+
class Client {
8+
9+
private $market;
10+
11+
private $manage;
12+
13+
private $engineer;
14+
15+
public function __construct() {
16+
$this->makeConProto();
17+
18+
$Tess=clone $this->market;
19+
$this->setEmployee($Tess,"Tess Smith",101,"ts101-1234","tess.png");
20+
$this->showEmployee($Tess);
21+
22+
$Jacob=clone $this->market;
23+
$this->setEmployee($Jacob,"Jacob Jones",102,"jj101-2234","jacob.png");
24+
$this->showEmployee($Jacob);
25+
26+
$Ricky=clone $this->manage;
27+
$this->setEmployee($Ricky,"Ricky Rodriguez",203,"rr203-5634","ricky.png");
28+
$this->showEmployee($Ricky);
29+
30+
$Olivia=clone $this->engineer;
31+
$this->setEmployee($Olivia,"Olivia Perez",302,"op301-1278","olivia.png");
32+
$this->showEmployee($Olivia);
33+
34+
$John=clone $this->engineer;
35+
$this->setEmployee($John,"John Jackson",301,"jj302-1454","john.png");
36+
$this->showEmployee($John);
37+
}
38+
39+
private function makeConProto() {
40+
$this->market=new Marketing();
41+
$this->manage=new Management();
42+
$this->engineer=new Engineering();
43+
}
44+
45+
private function showEmployee(IAcmePrototype $employeeNow) {
46+
$px=$employeeNow->getPic();
47+
echo "<img src=$px width='150' height='150'><br/>";
48+
echo $employeeNow->getName() . "<br/>";
49+
echo $employeeNow->getDept() . ": " . $employeeNow::UNIT . "<br/>";
50+
echo $employeeNow->getID() . "<p/>";
51+
}
52+
53+
private function setEmployee(IAcmePrototype $employeeNow,$nm,$dp,$id,$px) {
54+
$employeeNow->setName($nm);
55+
$employeeNow->setDept($dp);
56+
$employeeNow->setID($id);
57+
$employeeNow->setPic("pix/$px");
58+
}
59+
}
60+
61+
$worker = new Client();
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
<?php
2+
3+
include_once('IAcmePrototype.php');
4+
5+
class Engineering extends IAcmePrototype {
6+
7+
const UNIT="Engineering";
8+
9+
private $development="programming";
10+
11+
private $design="digital artwork";
12+
13+
private $sysAd="system administration";
14+
15+
public function setDept($orgCode) {
16+
switch($orgCode) {
17+
case 301:
18+
$this->dept=$this->development;
19+
break;
20+
21+
case 302:
22+
$this->dept=$this->design;
23+
break;
24+
25+
case 303:
26+
$this->dept=$this->sysAd;
27+
break;
28+
29+
default:
30+
$this->dept="Unrecognized Engineering";
31+
}
32+
}
33+
34+
public function getDept() {
35+
return $this->dept;
36+
}
37+
38+
function __clone(){}
39+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
//IAcmePrototype.php
3+
abstract class IAcmePrototype {
4+
5+
protected $name;
6+
7+
protected $id;
8+
9+
protected $employeePic;
10+
11+
protected $dept;
12+
13+
//Dept
14+
abstract function setDept($orgCode);
15+
16+
abstract function getDept();
17+
18+
//Name
19+
public function setName($emName) {
20+
$this->name=$emName;
21+
}
22+
public function getName() {
23+
return $this->name;
24+
}
25+
//ID
26+
public function setId($emId) {
27+
$this->id=$emId;
28+
}
29+
public function getId() {
30+
return $this->id;
31+
}
32+
//Employee Picture
33+
public function setPic($ePic) {
34+
$this->employeePic=$ePic;
35+
}
36+
37+
public function getPic() {
38+
return $this->employeePic;
39+
}
40+
41+
abstract function __clone();
42+
43+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
//Management.php
3+
include_once('IAcmePrototype.php');
4+
class Management extends IAcmePrototype {
5+
6+
const UNIT="Management";
7+
8+
private $research="research";
9+
10+
private $plan="planning";
11+
12+
private $operations="operations";
13+
14+
public function setDept($orgCode) {
15+
switch($orgCode) {
16+
case 201:
17+
$this->dept=$this->research;
18+
break;
19+
case 202:
20+
$this->dept=$this->plan;
21+
break;
22+
case 203:
23+
$this->dept=$this->operations;
24+
break;
25+
default:
26+
$this->dept="Unrecognized Management";
27+
}
28+
}
29+
30+
public function getDept() {
31+
return $this->dept;
32+
}
33+
34+
function __clone(){}
35+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
//Marketing.php
3+
include_once('IAcmePrototype.php');
4+
class Marketing extends IAcmePrototype {
5+
6+
const UNIT="Marketing";
7+
8+
private $sales="sales";
9+
10+
private $promotion="promotion";
11+
12+
private $strategic="strategic planning";
13+
14+
public function setDept($orgCode) {
15+
switch($orgCode) {
16+
case 101:
17+
$this->dept=$this->sales;
18+
break;
19+
case 102:
20+
$this->dept=$this->promotion;
21+
break;
22+
case 103:
23+
$this->dept=$this->strategic;
24+
break;
25+
default:
26+
$this->dept="Unrecognized Marketing ";
27+
}
28+
}
29+
30+
public function getDept() {
31+
return $this->dept;
32+
}
33+
34+
function __clone(){}
35+
}

0 commit comments

Comments
 (0)