Witam.
Prosze was o sprawdzenie klasy oraz wyrzucenie mi wszystkich błędów co jest nie tak jak być powinno.
Jest nie skończona ale wszytsko działa tak jak chciałem.
<?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;
private $people;
//public $window;
private $roof;
public function __construct($room, $height, $area, $people, $window, $roof) {
$this->room = $room;
$this->height = $height;
$this->area = $area;
if(!empty($window)) $this->window = $window; if(!empty($people)) $this->people = $people; if(!empty($roof)) $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;
}
}
?>