Exemple #1
0
                $this->costtype = self::FIXED;
                return 30;
        }
    }
    function chargeType()
    {
        switch ($this->costtype) {
            case self::TIMED:
                return "hourly rate";
                break;
            case self::FIXED:
                return "fixed rate";
                break;
            default:
                $this->costtype = self::FIXED;
                return "fixed rate";
        }
    }
}
class Lecture extends Lesson
{
}
class Seminar extends Lesson
{
}
$lecture = new Lecture(5, Lesson::FIXED);
echo get_class($lecture);
print "{$lecture->cost()} ({$lecture->chargeType()}) \n";
$seminar = new Seminar(3, Lesson::TIMED);
print "{$seminar->cost()} ({$seminar->chargeType()})\n";