| | 1 | | namespace CalculatorLibrary { |
| | 2 | | /// \brief A class for performing basic arithmetic operations. |
| | 3 | | public class Calculator { |
| | 4 | | /// \brief Adds two integers. |
| | 5 | | /// \param a The first integer to add. |
| | 6 | | /// \param b The second integer to add. |
| | 7 | | /// \return The sum of \a a and \a b. |
| | 8 | | public int Add(int a, int b) { |
| 2 | 9 | | return a + b; |
| | 10 | | } |
| | 11 | |
|
| | 12 | | /// \brief Subtracts two integers. |
| | 13 | | /// \param a The first integer to subtract from. |
| | 14 | | /// \param b The second integer to subtract. |
| | 15 | | /// \return The result of subtracting \a b from \a a. |
| | 16 | | public int Subtract(int a, int b) { |
| 2 | 17 | | return a - b; |
| | 18 | | } |
| | 19 | |
|
| | 20 | | /// \brief Multiplies two integers. |
| | 21 | | /// \param a The first integer to multiply. |
| | 22 | | /// \param b The second integer to multiply. |
| | 23 | | /// \return The product of \a a and \a b. |
| | 24 | | public int Multiply(int a, int b) { |
| 2 | 25 | | return a * b; |
| | 26 | | } |
| | 27 | |
|
| | 28 | | /// \brief Divides two integers. |
| | 29 | | /// \param a The numerator. |
| | 30 | | /// \param b The denominator. |
| | 31 | | /// \return The result of dividing \a a by \a b. |
| | 32 | | /// \throw DivideByZeroException if \a b is zero. |
| | 33 | | public int Divide(int a, int b) { |
| 4 | 34 | | if (b == 0) { |
| 2 | 35 | | throw new DivideByZeroException(); |
| | 36 | | } |
| | 37 | |
|
| 2 | 38 | | return a / b; |
| | 39 | | } |
| | 40 | |
|
| | 41 | | } |
| | 42 | | } |