| 1234567891011121314151617181920212223242526272829303132 |
- namespace Day19;
- public class Part
- {
- private readonly IDictionary<string, int> _dict;
- public int X => _dict["x"];
- public int M => _dict["m"];
- public int S => _dict["s"];
- public int A => _dict["a"];
- public int Total => X + M + S + A;
- public Part(IDictionary<string, int> dict)
- {
- if (string.Join(string.Empty, dict.Keys.Order()) != "amsx")
- {
- throw new ArgumentException("Expected dictionary with keys amsx", nameof(dict));
- }
- _dict = dict;
- }
- public int Get(string property)
- {
- return _dict[property];
- }
- public override string ToString()
- {
- return $"x = {X}, m = {M}, a = {A}, s = {S}, ";
- }
- }
|