public function work() { if ($this->allWork->isAllWorkDone() && $this->currentTask->getWorkingHours() == 0) { echo 'No more tasks !!!' . PHP_EOL; return true; } if ($this->hoursLeft == 0) { $this->startWorkingDay(); } if (!$this->getCurrentTask()) { $this->setCurrentTask($this->allWork->getNextTask()); } if ($this->currentTask->getWorkingHours() >= $this->hoursLeft) { echo $this->name . ' is working on task ' . $this->currentTask->getName() . ' for ' . $this->hoursLeft . ' hours.' . PHP_EOL; $this->currentTask->setWorkingHours($this->currentTask->getWorkingHours() - $this->hoursLeft); $this->hoursLeft = 0; } else { echo $this->name . ' is working on task ' . $this->currentTask->getName() . ' for ' . $this->currentTask->getWorkingHours() . ' hours.' . PHP_EOL; $this->hoursLeft = $this->hoursLeft - $this->currentTask->getWorkingHours(); $this->currentTask->setWorkingHours('0'); if (!$this->allWork->isAllWorkDone()) { $this->setCurrentTask($this->allWork->getNextTask()); } } if ($this->hoursLeft > 0) { $this->work(); } }
<?php /** * Created by PhpStorm. * User: just * Date: 20.02.16 * Time: 09:20 */ require_once 'class/autoload.php'; $allTask = new AllWork(); $task1 = new Task('Task1', 1); $task2 = new Task('Task2', 5); $task3 = new Task('Task3', 3); $task4 = new Task('Task4', 7); $task5 = new Task('Task5', 9); $task6 = new Task('Task6', 13); $task7 = new Task('Task7', 20); $task8 = new Task('Task8', 32); $task9 = new Task('Task9', 40); $task10 = new Task('Task10', 15); $allTask->addTask($task1); $allTask->addTask($task2); $allTask->addTask($task3); $allTask->addTask($task4); $allTask->addTask($task5); $allTask->addTask($task6); $allTask->addTask($task7); $allTask->addTask($task8); $allTask->addTask($task9); $allTask->addTask($task10); $employ = [new Employee('b1'), new Employee('b2'), new Employee('b3'), new Employee('b4'), new Employee('b5')];
<?php require_once 'Employee.php'; require_once 'AllWork.php'; require_once 'Task.php'; $allwork = new AllWork(); $task1 = new Task("Task1", 6); $allwork->addTask($task1); $task2 = new Task("Task2", 5); $allwork->addTask($task2); $task3 = new Task("Task3", 3); $allwork->addTask($task3); $task4 = new Task("Task4", 5); $allwork->addTask($task4); $task5 = new Task("Task5", 8); $allwork->addTask($task5); $task6 = new Task("Task6", 4); $allwork->addTask($task6); $task7 = new Task("Task7", 4); $allwork->addTask($task7); $task8 = new Task("Task8", 6); $allwork->addTask($task8); $task9 = new Task("Task9", 7); $allwork->addTask($task9); $task10 = new Task("Task10", 2); $allwork->addTask($task10); $employee1 = new Employee("Ivan Dimitrov"); $employee2 = new Employee("Marina Krasimirova"); $employee3 = new Employee("Stoqn Krystev");
<?php require_once 'autoload.php'; $t1 = new Task("Task 1", 15); $t2 = new Task("Task 2", 4); $t3 = new Task("Task 3", 6); $t4 = new Task("Task 4", 1); $t5 = new Task("Task 5", 32); $t6 = new Task("Task 6", 40); $t7 = new Task("Task 7", 18); $t8 = new Task("Task 8", 2); $t9 = new Task("Task 9", 3); $t10 = new Task("Task 10", 2); $t11 = new Task("Task 11", 2); $t12 = new Task("Task 12", 2); $allWork = new AllWork(); $allWork->addTask($t1); $allWork->addTask($t2); $allWork->addTask($t3); $allWork->addTask($t4); $allWork->addTask($t5); $allWork->addTask($t6); $allWork->addTask($t7); $allWork->addTask($t8); $allWork->addTask($t9); $allWork->addTask($t10); $allWork->addTask($t11); $allWork->addTask($t12); $e1 = new Employee("Ivan", $allWork); $e2 = new Employee("Niki", $allWork); $e3 = new Employee("Tina", $allWork);