HomeChallengesRepsProblemsLeaderboardTake a challenge

Types that say what they are

A mutable class and a ladder of if/else. Make the type immutable and the decision one expression.

Beginner18 min on the clock5 graded checks · 100 pointsC# FoundationsPro
Graded by reading your code against the checklist below.

What you build

  • Turn the shipment into a record
  • Make its properties settable only at construction
  • Replace the if/else ladder with a switch expression
  • Match on the properties rather than reading them one at a time
  • Produce a changed copy without mutating the original

Done means

Same prices, a type nobody can mutate, and a decision in one expression.

How it is graded

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

  1. Declare it as a record+25Records and pattern matching
  2. Settable at construction, not afterwards+15Records and pattern matching
  3. One switch expression, not a ladder+25Records and pattern matching
  4. Copy with a change instead of mutating+20Records and pattern matching
  5. Match on properties+15Records and pattern matching

What it teaches

The rest of C# Foundations