Sun Oct 26, 2008 11:32 pm
<?php
class Employee {
public $title;
public $lastName;
public $firstName;
public $price;
function __construct( $title, $firstName, $mainName, $price ) {
$this->title = $title;
$this->firstName = $firstName;
$this->lastName = $mainName;
$this->price = $price;
}
function getFullName() {
return "{$this->firstName}" . " {$this->lastName}";
}
}
class EmployeeWriter {
public function write( $shopProduct ) {
$str = "{$shopProduct->title}: ";
$str .= $shopProduct->getFullName();
$str .= " ({$shopProduct->price})\n";
print $str;
}
}
$product1 = new Employee( "Title", "A", "B", 5.9 );
$writer = new EmployeeWriter();
$writer->write( $product1 );
?>
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com
Powered by phpBB © phpBB Group.