CJCoding With Joseph
TitleTopicsAction
452
Private Field with a GetterCreate a class `Person` with a `private` field for a name (set through the const...
easy○ Not Started
Encapsulation
Solve
453
Getter and Setter MethodsCreate a class `Thermostat` with a `private int` field `temperature`. Add a `Set...
easy○ Not Started
Encapsulation
Solve
454
Auto-Implemented PropertiesCreate a class `Product` with two auto-implemented properties: `Name` (a `string...
easy○ Not Started
Encapsulation
Solve
455
Read-Only PropertyCreate a class `Circle` whose constructor stores a `private double radius`. Add ...
easy○ Not Started
Encapsulation
Solve
456
Computed Full Name PropertyCreate a class `Contact` whose constructor stores a `private` first name and las...
easy○ Not Started
Encapsulation
Solve
457
Deposit Into a Private BalanceCreate a class `Account` with a `private double balance` that starts at 0. Add a...
easy○ Not Started
Encapsulation
Solve
458
Property With a Private SetterCreate a class `Counter` with a `Count` property that has a public `get` but a `...
easy○ Not Started
Encapsulation
Solve
459
Expression-Bodied PropertyCreate a class `Rectangle` whose constructor stores a `private int width` and `h...
easy○ Not Started
Encapsulation
Solve
460
Read-Only FieldCreate a class `IdCard` with a `public readonly string Name` field. A `readonly`...
easy○ Not Started
Encapsulation
Solve
461
Toggle a Private BooleanCreate a class `LightSwitch` with a `private bool isOn` that starts `false`. Add...
easy○ Not Started
Encapsulation
Solve
462
Format a Field as a StringCreate a class `Battery` whose constructor stores a `private int level`. Add a r...
easy○ Not Started
Encapsulation
Solve
463
Property With a Backing FieldCreate a class `User` with a `private string name` backing field and a public `N...
easy○ Not Started
Encapsulation
Solve
464
Computed Boolean PropertyCreate a class `Voter` whose constructor stores a `private int age`. Add a read-...
easy○ Not Started
Encapsulation
Solve
477
Getter MethodThe `Student` class stores a private field `name` set by the constructor. Add a ...
easy○ Not Started
Encapsulation
Solve
478
Auto-Implemented PropertyGive the `Book` class a public auto-implemented property named `Title` of type `...
easy○ Not Started
Encapsulation
Solve
479
Read-Only Computed PropertyThe `Rectangle` class stores private `width` and `height` fields set by the cons...
easy○ Not Started
Encapsulation
Solve
480
Backing Field PropertyThe `Thermostat` class has a private field `temperature`. Add a public property ...
easy○ Not Started
Encapsulation
Solve
482
Private SetterThe `Product` class should expose a `Name` property that anyone can read but onl...
easy○ Not Started
Encapsulation
Solve
484
Normalizing Input in a SetterThe `Coupon` class has a private field `code`. Add a `Code` property whose `get`...
easy○ Not Started
Encapsulation
Solve
486
Default for Empty InputThe `Profile` class has a private field `name`. Add a `Name` property whose `get...
easy○ Not Started
Encapsulation
Solve
489
Constant FieldThe `TimeConverter` class should define a public constant `DaysInWeek` equal to ...
easy○ Not Started
Encapsulation
Solve
490
Static Instance CounterThe `Widget` class keeps a private static field `count` that increases by 1 each...
easy○ Not Started
Encapsulation
Solve
493
Private Helper MethodThe `Calculator` class exposes a public method `SumOfSquares(int a, int b)` that...
easy○ Not Started
Encapsulation
Solve
495
Read-Only Property from ConstructorThe `Box` class should have a get-only auto-property `Size` that is assigned onc...
easy○ Not Started
Encapsulation
Solve
498
Toggling Encapsulated StateThe `LightSwitch` class has a private `bool` field `isOn` that starts `false`. A...
easy○ Not Started
Encapsulation
Solve
500
Increment with Private SetThe `Counter` class has a `Count` property with a public getter and a private se...
easy○ Not Started
Encapsulation
Solve
465
Validate in a SetterCreate a class `Student` with a `private int age`. Write `SetAge(int value)` so ...
medium○ Not Started
Encapsulation
Solve
466
Clamp a Property to a RangeCreate a class `Volume` with a `private int level`. Its `Level` property returns...
medium○ Not Started
Encapsulation
Solve
467
Reject an Invalid SpendCreate a class `Wallet` whose constructor sets a `private double balance`. `Spen...
medium○ Not Started
Encapsulation
Solve
468
Init-Only PropertyCreate a class `Config` with a `string` property `Name` that can be set only dur...
medium○ Not Started
Encapsulation
Solve
469
Encapsulate a ListCreate a class `TodoList` that keeps a `private List<string>` of items. Callers ...
medium○ Not Started
Encapsulation
Solve
470
Count Instances With a Static FieldCreate a class `Widget` with a `private static int count`. Each time a `Widget` ...
medium○ Not Started
Encapsulation
Solve
471
Computed Property With LogicCreate a class `Order` whose constructor stores a `private double total`. Add a ...
medium○ Not Started
Encapsulation
Solve
472
Two Properties, One FieldCreate a class `Temperature` backed by a `private double celsius`. A `Celsius` p...
medium○ Not Started
Encapsulation
Solve
473
Average of an Encapsulated ListCreate a class `Gradebook` that stores scores in a `private List<int>`. `AddScor...
medium○ Not Started
Encapsulation
Solve
481
Guarding Against NegativesThe `Account` class has a private field `balance`. Add a `Balance` property whos...
medium○ Not Started
Encapsulation
Solve
483
Deposit and WithdrawThe `Wallet` class has a private field `balance` that starts at 0. Add `Deposit(...
medium○ Not Started
Encapsulation
Solve
485
ToString OverrideThe `Fraction` class stores private `numerator` and `denominator` fields set by ...
medium○ Not Started
Encapsulation
Solve
487
Constructor OverloadingThe `Timer` class has a private field `seconds`. Give it TWO constructors: a par...
medium○ Not Started
Encapsulation
Solve
491
Validation Method Returning BoolThe `User` class has a private field `age`. Add `SetAge(int value)` that stores ...
medium○ Not Started
Encapsulation
Solve
492
Monotonic OdometerThe `Odometer` class has a private field `miles`. A real odometer can never run ...
medium○ Not Started
Encapsulation
Solve
497
Temperature Conversion PropertyThe `Thermometer` class has a private field `celsius`. Add a `Celsius` property ...
medium○ Not Started
Encapsulation
Solve
499
Derived Boolean PropertyThe `Person` class has an auto-property `Age`. Add a read-only property `IsAdult...
medium○ Not Started
Encapsulation
Solve
474
Encapsulated Bank AccountBuild a class `BankAccount` from scratch. Requirements: - a `private double` bal...
hard○ Not Started
Encapsulation
Solve
475
Encapsulated StackBuild a class `NumberStack` that hides a `private List<int>`. Provide: - `Push(i...
hard○ Not Started
Encapsulation
Solve
476
Encapsulated State MachineBuild a class `TrafficLight` that hides its current color in a `private string` ...
hard○ Not Started
Encapsulation
Solve
488
Immutable Money TypeThe `Money` class stores two `readonly` fields, `amount` (int) and `currency` (s...
hard○ Not Started
Encapsulation
Solve
494
Roster Behind a Private ListThe `Team` class hides a private `List<string>` of member names. Add a method `A...
hard○ Not Started
Encapsulation
Solve
496
Validated RectangleBuild the `Rectangle` class with two properties `Width` and `Height`. Each sette...
hard○ Not Started
Encapsulation
Solve
501
Inventory Stock ControlThe `Inventory` class tracks a private field `quantity` that starts at 0. Add `A...
hard○ Not Started
Encapsulation
Solve