~rocktech.pl, myśle że "doc comment" sobie odpuścimy
proszę o sprawdzenie kodu czy jest to napisane w dość dobry sposób
pozdrawiam
<?php
class AirConditioning
{
const HOME = 20;
const HOME_ROOF = 0.2;
const COMPANY = 10;
const COMPANY_PERCENT = 0.1;
const COMPANY_ROOF = 0.1;
const PEOPLE = 0.1;
public $people;
public $roof;
public function __construct ($room, $height, $area, $people, $window, $roof)
{
$this->room = $room;
$this->height = $height;
$this->area = $area;
$this->window = $window;
}
$this->people = $people;
}
$this->roof = $roof;
}
}
public function check ()
{
if ($this->room == 0) {
return $this->home($this->height, $this->area);
}
if ($this->room == 1) {
return $this->company($this->height, $this->area);
}
}
public function home ($height, $area)
{
$count = $height * $area / self::HOME;
if ($this->roof == 1) {
$roof = self::HOME_ROOF;
}
if ($this->people > 0) {
$people = $this->people($this->people);
}
if (isset($roof) and
$roof > 0
) { $count = $count + $count * $roof;
}
if (isset($people) and
$people > 0
) { $count = $count + $people;
}
return $count;
}
public function company ($height, $area)
{
$count = $height * $area;
$count = $count / self::COMPANY;
$add = self::COMPANY_PERCENT;
if ($this->roof == 1) {
$add += self::COMPANY_ROOF;
}
if ($this->people > 0) {
$people = $this->people($this->people);
}
if (isset($roof) and
$roof > 0
) { $count = $count + $count * $roof;
}
if (isset($people) and
$people > 0
) { $count = $count + $people;
}
return $count;
}
public function people ($people)
{
$people = $people * self::PEOPLE;
return $people;
}
}
?>