HomeChallengesRepsProblemsLeaderboardTake a challenge

A kind of calendar

Records from another registry use the Julian rule: every fourth year is a leap year. Someone added JulianSchoolCalendar as a complete copy of SchoolCalendar, where only IsLeap differs. Make it a kind of SchoolCalendar instead.

Beginner15 min on the clock5 graded checks · 100 pointsObjects That Vary
Graded by reading your code against the checklist below.

What you build

  • Make JulianSchoolCalendar derive from SchoolCalendar
  • Delete everything it duplicates, keeping only its own IsLeap
  • Give it a constructor that forwards to the base with : base(...)
  • In Main, hold the Julian calendar in a variable declared as SchoolCalendar

Done means

The derived class holds one constructor and one method, chains to the base, and is used through a base-typed variable.

How it is graded

Published in full, before you start — every point is one of these and there is nothing else.

  1. JulianSchoolCalendar derives from SchoolCalendar+25Keeping the promises you inherit
  2. Nothing is duplicated in the derived class+25Keeping the promises you inherit
  3. The constructor chains with : base(...)+20Keeping the promises you inherit
  4. A SchoolCalendar variable holds the Julian calendar+20Keeping the promises you inherit
  5. Base fields stay private+10Objects that protect themselves

What it teaches

Keeping the promises you inheritadvanced

Anywhere the parent works the child must work too — and a subclass that compiles perfectly can still break the first caller who relied on something the parent quietly promised.

The rest of Objects That Vary