コード例 #1
0
 public static function main(array $args = array())
 {
     $tea = new Tea();
     $coffee = new Coffee();
     println("Making tea...");
     $tea->prepareRecipe();
     println("Making coffee...");
     $coffee->prepareRecipe();
 }
コード例 #2
0
ファイル: coffee.php プロジェクト: Toilon/samples
 public function __construct(CountryConfig $config)
 {
     parent::__construct($config);
 }
コード例 #3
0
ファイル: coffee-test.php プロジェクト: rdaitan/php-exercises
<?php

include 'Coffee.php';
$coffee = new Coffee();
$coffee->brand = 'Kopiko';
$coffee->name = 'Brown Coffee';
$coffee->net_wt = '25 g';
Coffee::printp($coffee);
$coffee2 = new Coffee('Nescafe', '3-in-1', '25 g');
Coffee::printp($coffee2);
コード例 #4
0
ファイル: main.php プロジェクト: pearpages/patterns-in-php
<?php

function __autoload($class_name)
{
    require_once $class_name . '.php';
}
$coffee = new Coffee();
$tea = new Tea();
$coffee->prepareRecipe();
$tea->prepareRecipe();
コード例 #5
0
ファイル: rio.php プロジェクト: saitomarch/POH6
    public function getTotal()
    {
        return $this->_water + $this->_powder;
    }
    public function taste($quantity)
    {
        $total = $this->getTotal();
        $this->_water -= $quantity * $this->_water / $total;
        $this->_powder -= $quantity * $this->_powder / $total;
    }
    public function getConsentration($asPercent)
    {
        return $this->_powder / $this->getTotal() * ($asPercent ? 100.0 : 1.0);
    }
}
$coffee = new Coffee();
$acts = (int) trim(fgets(STDIN));
for ($count = 0; $count < $acts; $count++) {
    $arr = split(" ", trim(fgets(STDIN)));
    $actType = (int) $arr[0];
    $quantity = (int) $arr[1];
    switch ($actType) {
        case 1:
            $coffee->addWater($quantity);
            break;
        case 2:
            $coffee->addPowder($quantity);
            break;
        case 3:
            $coffee->taste($quantity);
            break;
コード例 #6
0
ファイル: Coffee.php プロジェクト: rdaitan/php-exercises
 static function printp(Coffee $coffee)
 {
     print "<p>{$coffee->getFullName()} | {$coffee->net_wt}</p>";
 }
コード例 #7
0
<?php

include 'Coffee.php';
$coffee = new Coffee();
$coffee->brand = 'Kopiko';
$coffee->name = 'Brown Coffee';
$coffee->net_wt = '25 g';
$coffee->getWtUnit = function () use($coffee) {
    $unit = array();
    preg_match('/^[[:digit:]]+ ([[:alpha:]]+)$/', $coffee->net_wt, $unit);
    return $unit[1];
};
var_dump($coffee->getWtUnit());