Beispiel #1
0
        echo $this->showDescription();
    }
    public function showDescription()
    {
        return $this->os . " Memory;" . $this->RAM . " CPU;" . $this->CPU;
    }
}
$pc = new PC(2.5, 2000, "MAC OS", "Desctop");
$pc->showInfo();
$pc->CPU = 2.7;
echo '<br><br>';
$pc->showInfo();
echo '<br><br>';
echo $pc;
echo "<hr><div style='height:10px; background-color:red;'></div>";
$pc2 = new PC(3.5, 7000, "Windows XP", "Tower");
$pc3 = clone $pc2;
$pc2->showInfo();
$pc2->CPU = 2.7;
echo '<br><br>';
$pc2->showInfo();
echo '<br><br>';
echo $pc2;
echo "<hr><div style='height:10px; background-color:red;'></div>";
$pc3->showInfo();
//$pc3->CPU = 2.7;
echo '<br><br>';
$pc3->showInfo();
echo '<br><br>';
echo $pc3;
echo "<hr><div style='height:10px; background-color:red;'></div>";
Beispiel #2
0
    private $type;
    private $os;
    private $software = array();
    public function __construct($w, $h, $os, $t, $sw)
    {
        parent::__construct($w, $h);
        $this->os = $os;
        $this->type = $t;
        $this->software = $this->parseProgramms($sw);
    }
    public function showInfo()
    {
        parent::showInfo();
        echo '<br>';
        echo '<pre>';
        print_r($this->software);
        echo '</pre>';
    }
    private function parseProgramms($string)
    {
        $programms = explode(";", $string);
        for ($i = 0; $i < count($programms); $i++) {
            $info = explode("|", $programms[$i]);
            $this->software[$info[0]] = $info[1];
        }
        return $this->software;
    }
}
$computer = new PC(300, 250, "windows 8", 'laptop', 'Name|C:/PF/np.exe;Name2|C:/PF/np2.exe');
$computer->showInfo();
echo $computer->sum(10, 20);