Challenge 3 / 3
The intern has gone crazy with constants, by even making the hex strings into constants:
class GasPlanet implements PlanetInterface
{
// ...
const COLOR_BROWN_ISH = '663300';
const COLOR_BLUE_BRIGHT = '0066FF';
const COLOR_GRAY_DARK = '464646';
// ...
public function getHexColor()
{
// a "fake" map of elements to colors
switch ($this->mainElement) {
case GasPlanet::MATERIAL_AMMONIA:
return GasPlanet::COLOR_BROWN_ISH;
case GasPlanet::MATERIAL_METHANE:
return GasPlanet::COLOR_BLUE_BRIGHT;
default:
return GasPlanet::COLOR_GRAY_DARK;
}
}
}
Is this a good step forward?
Skip challenges and go to theNext Chapter