php;">
dept;
}
//员工ID号设置方法
public function setId($id)
{
$this->id = $id;
}
//员工ID号获取方法
public function getId()
{
return $this->id;
}
//员工名字设置方法
public function setName($
Name)
{
$this->name = $name;
}
//员工名字获取方法
public function getName()
{
return $this->name;
}
}
//市场部类
class Marke
Ting extends IAcmePrototype
{
const UNIT = "Marke
Ting"; //标识
//市场部门类别
private $
SALEs = "
SALEs";
private $promotion = "promotion";
private $strategic = "strategic pl
Anning";
//克隆函数
function __clone()
{
}
//部门设置函数
public function setDept($orgCod
E)
{
switch($orgCod
E)
{
case 101:
$this->dept = $this->
SALEs;
break;
case 102:
$this->dept = $this->promotion;
break;
case 103:
$this->dept = $this->strategi
c;
break;
default:
$this->dept = "Unrecognized Marke
Ting";
}
}
}
//管理部类
class Management extends IAcmePrototype
{
const UNIT = "Management";
private $research = "research";
private $plan = "pl
Anning";
private $operations = "operations";
function __clone()
{
}
public function setDept($orgCod
E)
{
switch($orgCod
E)
{
case 201:
$this->dept = $this->research;
break;
case 202:
$this->dept = $this->plan;
break;
case 203:
$this->dept = $this->operations;
break;
default:
$this->dept = "Unrecognized Marke
Ting";
}
}
}
//工厂部类
class
ENGIneering extends IAcmePrototype
{
const UNIT = "
ENGIneering";
private $development = "progr
AMMing";
private $design = "digital artwork";
private $sysAd = "system administration";
function __clone()
{
}
public function setDept($orgCod
E)
{
switch($orgCod
E)
{
case 301:
$this->dept = $this->development;
break;
case 302:
$this->dept = $this->design;
break;
case 303:
$this->dept = $this->sysAd;
break;
default:
$this->dept = "Unrecognized Marke
Ting";
}
}
}
//客户类
class Client
{
private $market; //市场部类实例
private $manage; //管理部类实例
private $
ENGIneer; //工厂部类实例
//构造函数
public function __construct()
{
$this->makeConProto(
);
//市场部类实例克隆
$Tess = clone $this->market;
$this->set
employee($Tess,"Tess Smith",101,"ts101-1234"
);
$this->show
employee($Tess
);
$Jacob = clone $this->market;
$this->set
employee($Jacob,"Jacob Jo
nes",102,"jj101-2234"
);
$this->show
employee($Jacob
);
//管理部类实例克隆
$Ricky = clone $this->manage;
$this->set
employee($Ricky,"Ricky Rodrigues",203,"rr203-5634"
);
$this->show
employee($Ricky
);
//工程部类实例克隆
$Olivia = clone $this->
ENGIneer;
$this->set
employee($Olivia,"Olivia perez",302,"op302-1278"
);
$this->show
employee($Olivia
);
$John = clone $this->
ENGIneer;
$this->set
employee($John,"John Jackson",301,"jj301
-1454"
);
$this->show
employee($John
);
}
//实例化部门对象
private function makeConProto()
{
$this->market = new Marke
Ting(
);
$this->manage = new Management(
);
$this->
ENGIneer = new
ENGIneering(
);
}
//员工信息设置方法
private function set
employee(IAcmePrototype $
employee,$name,$dept,$id)
{
$
employee->setName($
Name);
$
employee->setDept($dept
);
$
employee->setId($id
);
}
//员工信息显示方法
private function show
employee(IAcmePrototype $
employe
E)
{
echo $
employee->getName() . '
';
echo $
employee->getDept() . '
';
echo $
employee->getId() . '
';
}
}
$client = new Client(
);
?>