Source for file WeeklyTimesheet.php

Documentation is available at WeeklyTimesheet.php

  1. <?php
  2.  
  3. class WeeklyTimesheet {
  4.  
  5. public $standardHours;
  6. public $holidayHours;
  7. public $wage;
  8. public function __construct($sHours, $hHours) {
  9. $this->standardHours = $sHours;
  10. $this->holidayHours = $hHours;
  11. }
  12. public function calculatePay($wage) {
  13. if ($wage < 0)
  14. throw new Exception("Wage can't be negative");
  15.  
  16. if ($this->standardHours < 0 || $this->holidayHours < 0)
  17. throw new Exception("Hours can't be negative");
  18.  
  19. $extra = 0;
  20. $tempHours = $this->standardHours;
  21. if ($this->standardHours > 40) {
  22. $extra = $this->standardHours - 40;
  23. $tempHours = 40;
  24. }
  25. return $wage * ($tempHours + $extra * 1.5 + $this->holidayHours * 2);
  26.  
  27. }
  28. public function getTotalHours() {
  29. if ($this->standardHours < 0 || $this->holidayHours < 0)
  30. throw new Exception("Hours can't be negative");
  31. return $this->standardHours + $this->holidayHours;
  32. }
  33. }
  34.  
  35. ?>

Documentation generated on Sun, 02 Apr 2006 16:01:07 +0200 by phpDocumentor 1.3.0RC5