<?php
class Employee
{
public $name;
public $rate;
public function getTotalHoursWorked()
{
}
public function getSalary()
{
$hours = $this->getTotalHoursWorked();
$salary = $hours * $this->rate;
return $salary;
}
public function getShortName()
{
$pattern = "/[а-яё]+$/u";
$replace = '.';
return $z;
}
}
$ivan = new Employee;
$ivan->name = "Иванов Иван";
$ivan->rate = 10;
40,
40,
40,
40
);
$peter = new Employee;
$peter->name = "Петров Петр";
$peter->rate = 8;
40,
10,
40,
50
);
$ivan,
$peter
);
$col1 = 30;
$col2 = 16;
$col3 = 16;
$col4 = 16;
function padRight($string, $arg)
{
echo $string . $space;
}
function padLeft($string, $arg)
{
echo $space . $string;
}
echo padRight("Сотрудник", $col1) . padLeft("Часы", $col2) . padLeft("Ставка", $col3) . padLeft("З/п", $col4) . "\n\n";
$totalHrs = 0;
$totalRate = 0;
$totalSlr = 0;
foreach ($employees as $employee) {
$totalHrs += $employee->getTotalHoursWorked();
$totalRate += $employee->rate;
$totalSlr += $employee->getSalary();
}
foreach ($employees as $employee) {
echo padRight($employee->getShortName(), $col1) . padLeft($employee->getTotalHoursWorked(), $col2) . padLeft($employee->rate, $col3) . padLeft($employee->getSalary(), $col4) . "\n";
}
echo padRight('Всего : ', $col1) . padLeft($totalHrs, $col2) . padLeft($totalRate, $col3) . padLeft($totalSlr, $col4) . "\n";
Cjw/cGhwCgptYl9pbnRlcm5hbF9lbmNvZGluZygiVVRGLTgiKTsKCmNsYXNzIEVtcGxveWVlCnsKICAgIHB1YmxpYyAkbmFtZTsKICAgIHB1YmxpYyAkcmF0ZTsKICAgIHB1YmxpYyAkaG91cnMgPSBhcnJheSgpOwogICAgCiAgICBwdWJsaWMgZnVuY3Rpb24gZ2V0VG90YWxIb3Vyc1dvcmtlZCgpCiAgICB7CiAgICAgICAgcmV0dXJuIGFycmF5X3N1bSgkdGhpcy0+aG91cnMpOwogICAgfQogICAgcHVibGljIGZ1bmN0aW9uIGdldFNhbGFyeSgpCiAgICB7CiAgICAgICAgJGhvdXJzICA9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