public static function main(array $args = array())
 {
     $tea = new Tea();
     $coffee = new Coffee();
     println("Making tea...");
     $tea->prepareRecipe();
     println("Making coffee...");
     $coffee->prepareRecipe();
 }
Exemple #2
0
 public function __construct(CountryConfig $config)
 {
     parent::__construct($config);
 }
<?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);
Exemple #4
0
<?php

function __autoload($class_name)
{
    require_once $class_name . '.php';
}
$coffee = new Coffee();
$tea = new Tea();
$coffee->prepareRecipe();
$tea->prepareRecipe();
Exemple #5
0
    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;
Exemple #6
0
 static function printp(Coffee $coffee)
 {
     print "<p>{$coffee->getFullName()} | {$coffee->net_wt}</p>";
 }
<?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());