@ 2015-03-05T22:13:57Z <?php
// camel case the class name
class Smth
{
// changed the static class variables to constants
const MARK_UNDEFINED = 'Undefined';
const MARK_F = 'ECTS-F';
const MARK_FX = 'ECTS-FX';
const MARK_E = 'ECTS-E';
const MARK_D = 'ECTS-D';
const MARK_C = 'ECTS-C';
const MARK_B = 'ECTS-B';
const MARK_A = 'ECTS-A';
// changed the protected method to public(no discernable reason to make it protected)
// changed the function name to camel case
public function getEctsMark($rate, $current, $examRate)
{
// moved this here to save us going through 2 if statements
if($current > 0 && $examRate < 22) {
return self::MARK_FX;
}
// the rest is the same as it was originally.
$color = self::MARK_UNDEFINED;
if ($current > 0) {
$percent = $rate / $current;
if ($percent < 0.31) {
$color = self::MARK_F;
} elseif ($percent < 0.60) {
$color = self::MARK_FX;
} elseif ($percent < 0.65) {
$color = self::MARK_E;
} elseif ($percent < 0.71) {
$color = self::MARK_D;
} elseif ($percent < 0.85) {
$color = self::MARK_C;
} elseif ($percent < 0.95) {
$color = self::MARK_B;
} else {
$color = self::MARK_A;
}
}
return $color;
}
}
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 5.0.0 - 5.0.5 , 5.1.0 - 5.1.6 , 5.2.0 - 5.2.17 , 5.3.0 - 5.3.29 , 5.4.0 - 5.4.45 , 5.5.0 - 5.5.38 , 5.6.0 - 5.6.28 , 7.0.0 - 7.0.20 , 7.1.0 - 7.1.33 , 7.2.0 - 7.2.33 , 7.3.0 - 7.3.33 , 7.4.0 - 7.4.33 , 8.0.0 - 8.0.30 , 8.1.0 - 8.1.33 , 8.2.0 - 8.2.29 , 8.3.0 - 8.3.26 , 8.4.1 - 8.4.13 Output for 4.4.2 - 4.4.9 Parse error: syntax error, unexpected T_CONST, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/QuveB on line 7
Process exited with code 255 . Output for 4.3.0 - 4.3.1 , 4.3.5 - 4.3.11 , 4.4.0 - 4.4.1 Parse error: parse error, unexpected T_CONST, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /in/QuveB on line 7
Process exited with code 255 . Output for 4.3.2 - 4.3.4 Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in /in/QuveB on line 7
Process exited with code 255 . preferences:dark mode live preview ace vim emacs key bindings
161.66 ms | 410 KiB | 5 Q