Skip to content

Instantly share code, notes, and snippets.

@lgolubyev
Created May 24, 2022 12:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lgolubyev/a9ceca9986aa92c102009d23b2a01a3e to your computer and use it in GitHub Desktop.
Save lgolubyev/a9ceca9986aa92c102009d23b2a01a3e to your computer and use it in GitHub Desktop.
Battery battery = new("CR2032", 0.235, 100);
WriteLine(battery);
while (battery.RemainingCapacityPercentage > 0)
{
Battery updatedBattery = battery with
{RemainingCapacityPercentage =
battery.RemainingCapacityPercentage - 1};
battery = updatedBattery;
}
WriteLine(battery);
public readonly record struct Battery(string Model, double TotalCapacityAmpHours, int RemainingCapacityPercentage);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment