CJCoding With Joseph
15free / daySign inCreate account
TitleTopicsAction
542
Private Field with a GetterCreate a class `Person` with a `private` field for a name (set through the const...
easy○ Not Started
Encapsulation
Solve
543
Getter and Setter MethodsCreate a class `Thermostat` with a `private int` field `temperature`. Add a `Set...
easy○ Not Started
Encapsulation
Solve
544
Auto-Implemented PropertiesCreate a class `Product` with two auto-implemented properties: `Name` (a `string...
easy○ Not Started
Encapsulation
Solve
545
Read-Only PropertyCreate a class `Circle` whose constructor stores a `private double radius`. Add ...
easy○ Not Started
Encapsulation
Solve
546
Computed Full Name PropertyCreate a class `Contact` whose constructor stores a `private` first name and las...
easy○ Not Started
Encapsulation
Solve
547
Deposit Into a Private BalanceCreate a class `Account` with a `private double balance` that starts at 0. Add a...
easy○ Not Started
Encapsulation
Solve
548
Property With a Private SetterCreate a class `Counter` with a `Count` property that has a public `get` but a `...
easy○ Not Started
Encapsulation
Solve
549
Expression-Bodied PropertyCreate a class `Rectangle` whose constructor stores a `private int width` and `h...
easy○ Not Started
Encapsulation
Solve
550
Read-Only FieldCreate a class `IdCard` with a `public readonly string Name` field. A `readonly`...
easy○ Not Started
Encapsulation
Solve
551
Toggle a Private BooleanCreate a class `LightSwitch` with a `private bool isOn` that starts `false`. Add...
easy○ Not Started
Encapsulation
Solve
552
Format a Field as a StringCreate a class `Battery` whose constructor stores a `private int level`. Add a r...
easy○ Not Started
Encapsulation
Solve
553
Property With a Backing FieldCreate a class `User` with a `private string name` backing field and a public `N...
easy○ Not Started
Encapsulation
Solve
554
Computed Boolean PropertyCreate a class `Voter` whose constructor stores a `private int age`. Add a read-...
easy○ Not Started
Encapsulation
Solve
567
Getter MethodThe `Student` class stores a private field `name` set by the constructor. Add a ...
easy○ Not Started
Encapsulation
Solve
568
Auto-Implemented PropertyGive the `Book` class a public auto-implemented property named `Title` of type `...
easy○ Not Started
Encapsulation
Solve
569
Read-Only Computed PropertyThe `Rectangle` class stores private `width` and `height` fields set by the cons...
easy○ Not Started
Encapsulation
Solve
570
Backing Field PropertyThe `Thermostat` class has a private field `temperature`. Add a public property ...
easy○ Not Started
Encapsulation
Solve
572
Private SetterThe `Product` class should expose a `Name` property that anyone can read but onl...
easy○ Not Started
Encapsulation
Solve
574
Normalizing Input in a SetterThe `Coupon` class has a private field `code`. Add a `Code` property whose `get`...
easy○ Not Started
Encapsulation
Solve
576
Default for Empty InputThe `Profile` class has a private field `name`. Add a `Name` property whose `get...
easy○ Not Started
Encapsulation
Solve
579
Constant FieldThe `TimeConverter` class should define a public constant `DaysInWeek` equal to ...
easy○ Not Started
Encapsulation
Solve
580
Static Instance CounterThe `Widget` class keeps a private static field `count` that increases by 1 each...
easy○ Not Started
Encapsulation
Solve
583
Private Helper MethodThe `Calculator` class exposes a public method `SumOfSquares(int a, int b)` that...
easy○ Not Started
Encapsulation
Solve
585
Read-Only Property from ConstructorThe `Box` class should have a get-only auto-property `Size` that is assigned onc...
easy○ Not Started
Encapsulation
Solve
588
Toggling Encapsulated StateThe `LightSwitch` class has a private `bool` field `isOn` that starts `false`. A...
easy○ Not Started
Encapsulation
Solve
590
Increment with Private SetThe `Counter` class has a `Count` property with a public getter and a private se...
easy○ Not Started
Encapsulation
Solve
555
Validate in a SetterCreate a class `Student` with a `private int age`. Write `SetAge(int value)` so ...
medium○ Not Started
Encapsulation
Solve
556
Clamp a Property to a RangeCreate a class `Volume` with a `private int level`. Its `Level` property returns...
medium○ Not Started
Encapsulation
Solve
557
Reject an Invalid SpendCreate a class `Wallet` whose constructor sets a `private double balance`. `Spen...
medium○ Not Started
Encapsulation
Solve
558
Init-Only PropertyCreate a class `Config` with a `string` property `Name` that can be set only dur...
medium○ Not Started
Encapsulation
Solve
559
Encapsulate a ListCreate a class `TodoList` that keeps a `private List<string>` of items. Callers ...
medium○ Not Started
Encapsulation
Solve
560
Count Instances With a Static FieldCreate a class `Widget` with a `private static int count`. Each time a `Widget` ...
medium○ Not Started
Encapsulation
Solve
561
Computed Property With LogicCreate a class `Order` whose constructor stores a `private double total`. Add a ...
medium○ Not Started
Encapsulation
Solve
562
Two Properties, One FieldCreate a class `Temperature` backed by a `private double celsius`. A `Celsius` p...
medium○ Not Started
Encapsulation
Solve
563
Average of an Encapsulated ListCreate a class `Gradebook` that stores scores in a `private List<int>`. `AddScor...
medium○ Not Started
Encapsulation
Solve
571
Guarding Against NegativesThe `Account` class has a private field `balance`. Add a `Balance` property whos...
medium○ Not Started
Encapsulation
Solve
573
Deposit and WithdrawThe `Wallet` class has a private field `balance` that starts at 0. Add `Deposit(...
medium○ Not Started
Encapsulation
Solve
575
ToString OverrideThe `Fraction` class stores private `numerator` and `denominator` fields set by ...
medium○ Not Started
Encapsulation
Solve
577
Constructor OverloadingThe `Timer` class has a private field `seconds`. Give it TWO constructors: a par...
medium○ Not Started
Encapsulation
Solve
581
Validation Method Returning BoolThe `User` class has a private field `age`. Add `SetAge(int value)` that stores ...
medium○ Not Started
Encapsulation
Solve
582
Monotonic OdometerThe `Odometer` class has a private field `miles`. A real odometer can never run ...
medium○ Not Started
Encapsulation
Solve
587
Temperature Conversion PropertyThe `Thermometer` class has a private field `celsius`. Add a `Celsius` property ...
medium○ Not Started
Encapsulation
Solve
589
Derived Boolean PropertyThe `Person` class has an auto-property `Age`. Add a read-only property `IsAdult...
medium○ Not Started
Encapsulation
Solve
564
Encapsulated Bank AccountBuild a class `BankAccount` from scratch. Requirements: - a `private double` bal...
hard○ Not Started
Encapsulation
Solve
565
Encapsulated StackBuild a class `NumberStack` that hides a `private List<int>`. Provide: - `Push(i...
hard○ Not Started
Encapsulation
Solve
566
Encapsulated State MachineBuild a class `TrafficLight` that hides its current color in a `private string` ...
hard○ Not Started
Encapsulation
Solve
578
Immutable Money TypeThe `Money` class stores two `readonly` fields, `amount` (int) and `currency` (s...
hard○ Not Started
Encapsulation
Solve
584
Roster Behind a Private ListThe `Team` class hides a private `List<string>` of member names. Add a method `A...
hard○ Not Started
Encapsulation
Solve
586
Validated RectangleBuild the `Rectangle` class with two properties `Width` and `Height`. Each sette...
hard○ Not Started
Encapsulation
Solve
591
Inventory Stock ControlThe `Inventory` class tracks a private field `quantity` that starts at 0. Add `A...
hard○ Not Started
Encapsulation
Solve