Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP]Sprawdzenie klasy
minolone
post
Post #1





Grupa: Zarejestrowani
Postów: 141
Pomógł: 24
Dołączył: 21.06.2008

Ostrzeżenie: (0%)
-----


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.
  1. <?php
  2.  
  3. print_r($_POST);
  4.  
  5. class AirConditioning {
  6.  
  7. const HOME = 20;
  8. const HOME_ROOF = 0.2;
  9. const COMPANY = 10;
  10. const COMPANY_PERCENT = 0.1;
  11. const COMPANY_ROOF = 0.1;
  12. const PEOPLE = 0.1;
  13.  
  14. private $people;
  15. //public $window;
  16. private $roof;
  17.  
  18. public function __construct($room, $height, $area, $people, $window, $roof) {
  19. $this->room = $room;
  20. $this->height = $height;
  21. $this->area = $area;
  22. if(!empty($window)) $this->window = $window;
  23. if(!empty($people)) $this->people = $people;
  24. if(!empty($roof)) $this->roof = $roof;
  25. }
  26.  
  27. public function check() {
  28. if($this->room == 0) {
  29. return $this->home($this->height, $this->area);
  30. }
  31. if($this->room == 1) {
  32. return $this->company($this->height, $this->area);
  33. }
  34. }
  35.  
  36. public function home($height, $area) {
  37. $count = $height*$area/self::HOME;
  38.  
  39. if($this->roof == 1) {
  40. $roof = self::HOME_ROOF;
  41. }
  42.  
  43. if($this->people > 0) {
  44. $people = $this->people($this->people);
  45. }
  46.  
  47. if(isset($roof) AND $roof > 0) {
  48. $count = $count+$count*$roof;
  49. }
  50.  
  51. if(isset($people) AND $people > 0) {
  52. $count = $count+$people;
  53. }
  54.  
  55. return $count;
  56. }
  57.  
  58. public function company($height, $area) {
  59. $count = $height*$area;
  60. $count = $count/self::COMPANY;
  61. $add = self::COMPANY_PERCENT;
  62.  
  63. if($this->roof == 1) {
  64. $add += self::COMPANY_ROOF;
  65. }
  66.  
  67. if($this->people > 0) {
  68. $people = $this->people($this->people);
  69. }
  70.  
  71. if(isset($roof) AND $roof > 0) {
  72. $count = $count+$count*$roof;
  73. }
  74.  
  75. if(isset($people) AND $people > 0) {
  76. $count = $count+$people;
  77. }
  78.  
  79. return $count;
  80. }
  81.  
  82. public function people($people) {
  83. $people = $people*self::PEOPLE;
  84. return $people;
  85. }
  86.  
  87. }
  88.  
  89. ?>




Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi
minolone
post
Post #2





Grupa: Zarejestrowani
Postów: 141
Pomógł: 24
Dołączył: 21.06.2008

Ostrzeżenie: (0%)
-----


~wookieb, ogólnie chodzi mi o sprawdzenie czy jest to jakoś tak w miare napisane, oraz ew. co powinienem zmienić, poprawić przy pisaniu.
Ogólnie to co chciałem uzyskać jest zrobione, czyli wylicza mi moc klimatyzatora tak jak powinno.

Ten post edytował minolone 17.02.2012, 14:26:10
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 13.10.2025 - 11:58