base class:
abstract class Challenge
{
abstract **static** public function getName();
}
now two classes from it:
class ChallengeType1 extends Challenge
{
public **static** function getName()
{
return 'Swimming';
}
}
class ChallengeType2 extends Challenge
{
public **static** function getName()
{
return 'Climbing';
}
}
as you all might know, we can't use static
, but it would be reasonable. So I can't do like that: for example, I have the classname, so I want to know it's name: ChallengeType2::getName();
- it will fail! First I should construct the object - looks unnecessary (not to mention, what it this class have very complex initialization?)