当前位置: 首页>>代码示例>>PHP>>正文


PHP Employee::recruit方法代码示例

本文整理汇总了PHP中Employee::recruit方法的典型用法代码示例。如果您正苦于以下问题:PHP Employee::recruit方法的具体用法?PHP Employee::recruit怎么用?PHP Employee::recruit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Employee的用法示例。


在下文中一共展示了Employee::recruit方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: array

abstract class Employee
{
    protected $name;
    private static $types = array('minion', 'cluedup', 'wellconnected');
    static function recruit($name)
    {
        $num = rand(1, count(self::$types)) - 1;
        $class = self::$types[$num];
        return new $class($name);
    }
    function __construct($name)
    {
        $this->name = $name;
    }
    abstract function fire();
}
// new Employee class...
class WellConnected extends Employee
{
    function fire()
    {
        print "{$this->name}: I'll call my dad\n";
    }
}
$boss = new NastyBoss();
$boss->addEmployee(Employee::recruit("harry"));
$boss->addEmployee(Employee::recruit("bob"));
$boss->addEmployee(Employee::recruit("mary"));
$boss->projectFails();
$boss->projectFails();
$boss->projectFails();
开发者ID:jabouzi,项目名称:projet,代码行数:31,代码来源:listing9.03.php

示例2: fire

    }
}
class WellConnected extends Employee
{
    function fire()
    {
        print "{$this->name}: blablabla\n";
    }
}
class NastyBoss
{
    private $employees = array();
    function addEmployee(Employee $employee)
    {
        $this->employees[] = $employee;
    }
    function projectFails()
    {
        if (count($this->employees) > 0) {
            $emp = array_pop($this->employees);
            $emp->fire();
        }
    }
}
$employee = new NastyBoss();
$employee->addEmployee(Employee::recruit('Slava'));
$employee->addEmployee(Employee::recruit('Lidia'));
$employee->addEmployee(Employee::recruit('Nestor'));
$employee->projectFails();
$employee->projectFails();
$employee->projectFails();
开发者ID:beregsys,项目名称:Learning,代码行数:31,代码来源:SomePatterns.php

示例3: addEmployee

    {
        print "{$this->name}: убери со стола\n";
    }
}
class NastyBoss
{
    private $employees = [];
    function addEmployee(Employee $employee)
    {
        $this->employees[] = $employee;
    }
    function projectFails()
    {
        if (count($this->employees) > 0) {
            $emp = array_pop($this->employees);
            $emp->fire();
        }
    }
}
class ClueUp extends Employee
{
    function fire()
    {
        print "{$this->name}: вызови адвоката\n";
    }
}
$boss = new NastyBoss();
$boss->addEmployee(Employee::recruit("Игорь"));
$boss->addEmployee(Employee::recruit("Владимир"));
$boss->addEmployee(Employee::recruit("Мария"));
开发者ID:VitaOpus,项目名称:Patterns,代码行数:30,代码来源:example3.php

示例4: NastyBoss

<?php

$boss = new NastyBoss();
$boss->addEmployee(Employee::recruit("Bob"));
$boss->addEmployee(Employee::recruit("Steve"));
$boss->addEmployee(Employee::recruit("Lisa"));
$boss->projectFails();
$boss->projectFails();
$boss->projectFails();
开发者ID:Codealist,项目名称:patterns,代码行数:9,代码来源:index.php

示例5: fire

    }
}
class CluedUp extends Employee
{
    function fire()
    {
        echo $this->name . ': вызови адвоката';
    }
}
class NastyBoss
{
    private $employees = [];
    function addEmployee(Employee $employee)
    {
        $this->employees[] = $employee;
    }
    function projectFails()
    {
        if (count($this->employees) > 0) {
            $emp = array_pop($this->employees);
            $emp->fire();
        }
    }
}
$boss = new NastyBoss();
$boss->addEmployee(Employee::recruit('Игорь'));
$boss->addEmployee(Employee::recruit('Владимир'));
$boss->addEmployee(Employee::recruit('Мария'));
var_dump($boss);
$boss->projectFails();
var_dump($boss);
开发者ID:pers1307,项目名称:levelUpPHP,代码行数:31,代码来源:fabric.php


注:本文中的Employee::recruit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。