Witam
Już kiedyś pisałem że chciałem się wdrożyć w programowanie obiektowe w PHP

Napisałem cosbie taki oto kod składający się z 3 klas:
<?php
class Car{
protected $mark,$color,$mileage;
protected function __construct($mark,$color,$milleage){
$this->mark=$mark;
$this->color=$color;
$this->mileage=$milleage;
}
protected function getMark(){
return $this->mark;
}
protected function getColor(){
return $this->color;
}
protected function getMileage(){
return $this->mileage;
}
private function getAllPropertiesOfCar(){
return $this->getMark().' '.$this->getColor().' '.$this->getMileage();
}
}
class Person extends Car{
protected $name,$surname,$age,$profession,$auto;
protected function setName($name){
$this->name=$name;
}
protected function setSurname($surname){
$this->surname=$surname;
}
protected function setAgeAndProfession($age,$profession){
$this->age=$age; $this->profession=$profession;
}
protected function giveAllPropertiesOfPerson(){
print $this->name.' '.$this->surname.' '.$this->age.' '.$this->profession.'<br><br>';
}
public function chooseYourCar($mark,$color,$milleage){
$this->mark=$mark;
$this->color=$color;
$this->mileage=$milleage;
}
public function showNewCar(){
print $this->name. ' bought a new car. It`s: '.$this->getMark().' the color is: '.$this->getColor().' and the milleage is not to bad: '.$this->getMileage(); }
}
class Family extends Person{
private $address,$fortune,$volume;
function __construct($address,$fortune,$volume){
$this->address=$address;
$this->fortune=$fortune;
$this->volume=$volume;
}
public function addPerson($name,$surname,$age,$profession){
$this->setName($name);
$this->setSurname($surname);
$this->setAgeAndProfession($age,$profession);
}
public function printFamily(){
$this->giveAllPropertiesOfPerson();
}
public function printPropertiesOfFamilyCar(){
$this->showNewCar();
}
public function hugePersonOfFamily(Person $p){
return $this->name.' is hugging '. $p->name;
}
};
// CIAŁO
$family= new Family('London',240000,4);
$family->addPerson('John','Kowalski',46,'Programmer');
$family_a=new Family('Krakow',120000,2);
$family_a->addPerson('Izabel','Kowlaska',44,'Designer');
$family->printFamily();
$family_a->printFamily();
$family->chooseYourCar('volvo','red' ,230000 );
$family->showNewCar();
print $family->hugePersonOfFamily($family_a);
?>
Proszę znawców o zweryfikowanie czy dobrze rozumiem pojecie obiektowości. Zastosowałem oddzielne klasy dla obiektów, dodałem dla nich unikalne funkcje gdzie niekiedy inne obiekty korzystają z funkcji innych obiektów.
Proszę o opinie czy moje wypocinki można nazwać choź troszkę OOP

EDIT:
oto wynik zwracany przez powyższy kod
Kod
John Kowalski 46 Programmer
Izabel Kowlaska 44 Designer
John bought a new car. It`s: volvo the color is: red and the milleage is not to bad: 230000
John is hugging Izabel
Ten post edytował kosmos 30.05.2008, 20:30:47