All MicroEvals
t2-01-fleet-drone-energy
Create MicroEval
Header image for t2-01-fleet-drone-energy

t2-01-fleet-drone-energy

T2

Prompt

You are fixing a bug in a small C# file. Below is the full contents of `FleetSimulation.cs`, followed by the bug report. Reply with ONLY the complete corrected contents of `FleetSimulation.cs` in a single C# code block - no explanation before or after the code block. ## Current file: FleetSimulation.cs ```csharp namespace FleetEnergyKata; public sealed class Drone { public double Energy { get; set; } public double MaxEnergy { get; init; } public double RegenPerTick { get; init; } public double UpkeepDrainPerTick { get; init; } } public static class FleetTickProcessor { public static void Tick(Drone drone) { var afterRegen = drone.Energy + drone.RegenPerTick; afterRegen = Math.Clamp(afterRegen, 0, drone.MaxEnergy); drone.Energy = afterRegen - drone.UpkeepDrainPerTick; } } ``` ## Bug report `FleetTickProcessor.Tick(Drone drone)` is supposed to apply one tick of energy regeneration and one tick of upkeep drain to a drone, respecting `MaxEnergy` and never letting `Energy` go negative. QA reports that drones sitting near full charge do not lose energy to upkeep drain on ticks where regen would have pushed them over the cap - the drain seems to just disappear. A drone at 90/100 energy with `RegenPerTick = 50` and `UpkeepDrainPerTick = 10` should end the tick at 100 (net gain of 40, clamped to the cap), but currently ends the tick still at 90 (no net change at all). ## Your task Fix `Tick` so that regen and drain are applied together as one net change per tick, clamped to the valid range `[0, MaxEnergy]` only once, after both effects are accounted for. Do not change the `Drone` or `FleetTickProcessor` public API (field/property names and method signature must stay the same - other code depends on them). Make the smallest change that fixes the bug - do not restructure unrelated code or add new public members. Reply with ONLY the corrected `FleetSimulation.cs` file in one C# code block.