using System; namespace Chernobyl.Calculator { /// /// A version of an ICalculator that can perform /// calculations on ints. /// public struct UIntCalculator : ICalculator { /// /// Adds one uint to another. /// /// The left side of the addition operation. /// The right side of the addition operation. /// The result of the addition. public uint Add(uint left, uint right) { return left + right; } /// /// Subtracts one uint from another. /// /// The left side of the subtraction operation. /// The right side of the subtraction operation. /// The result of the subtraction. public uint Subtract(uint left, uint right) { return left - right; } /// /// Divides two uints. /// /// The dividend. /// The divisor. /// The result of the divide. public uint Divide(uint dividend, uint divisor) { return dividend / divisor; } /// /// Multiplies two uints together. /// /// The left side of the multiplication operation. /// The right side of the multiplication operation. /// The result of the multiplication. public uint Multiply(uint left, uint right) { return left * right; } /// /// Negates a uint. /// /// The uint to negate. /// The result of the negation. public uint Negate(uint item) { // uint can't go below 0 throw new Exception("Negate called on a UIntCalculator; uints cannot be negated because they are unsigned types."); } /// /// Compares two uints. /// /// The left side of the comparison operation. /// The right side of the comparison operation. /// True if the two are the same, false if otherwise. public bool Compare(uint left, uint right) { return (left == right); } } }