Conversation
📝 WalkthroughWalkthroughA new public Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
CSharp/Blackbaud.Interview.Cards/Deck.cs (1)
52-67:⚠️ Potential issue | 🔴 CriticalMove
Shuffleout ofNextCardto fix a compile error.The
Shufflemethod is currently nested insideNextCard()with apublicaccess modifier, which violates C# rules: access modifiers are not allowed on local functions. This code will not compile. Close theNextCard()method with a closing brace after the else block (line 60), then declareShuffleas a class member method.🐛 Proposed fix
else { return null; } - /// <summary> - /// Shuffles the deck a given number of times and returns a new shuffled deck. - /// </summary> - public Deck Shuffle(int times) - { + } + + /// <summary> + /// Shuffles the deck a given number of times and returns a new shuffled deck. + /// </summary> + public Deck Shuffle(int times) + {
🧹 Nitpick comments (2)
CSharp/Blackbaud.Interview.Cards/Deck.cs (2)
68-69: Prefer an out-of-range exception with parameter name for invalidtimes.
ArgumentOutOfRangeException(nameof(times), ...)yields clearer diagnostics for callers and is the idiomatic choice for this check.♻️ Proposed tweak
- if (times <= 0) - throw new ArgumentException("Number of shuffles must be greater than zero."); + if (times <= 0) + throw new ArgumentOutOfRangeException(nameof(times), "Number of shuffles must be greater than zero.");
73-79: UseRandom.Sharedinstead of per-callnew Random().Creating a new
Randominstance per call causes identical shuffle sequences whenShuffle()is invoked in quick succession, sinceRandomseeds from the system clock. Your project targets .NET 8.0, soRandom.Sharedis available and provides a thread-safe shared RNG instance that maintains state across calls.♻️ Proposed change
- var random = new Random(); + var random = Random.Shared;
Summary by CodeRabbit
New Features