HomeChallengesRepsProblemsLeaderboardTake a challenge

The part that varies

The leap-year rule is written out twice inside one method. Before anything can vary, it needs a name and one home.

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

What you build

  • Pull the leap-year test into one method, IsLeap(int year)
  • Call it from both places the expression used to be
  • Leave GetSchoolDate and the date arithmetic alone
  • Work out GetSchoolBirthday(20920229) by hand and fill in Answers.cs

Done means

One IsLeap method, the rule written once, both call sites using it, and the century case traced correctly.

How it is graded

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

  1. A single IsLeap(int year) method exists+25Let the object answer
  2. The rule is written exactly once+25Let the object answer
  3. Both places call IsLeap+20Let the object answer
  4. The century year is traced correctly+20Everything is a number underneath
  5. IsLeap reads only its argument+10Let the object answer

What it teaches

The rest of Objects That Vary