I have a class
class Rational
{
private int _n;
private int _m;
public Rational(int n, int m)
{
_n = n;
_m = m;
}
}
But m should be > 0. What should I do to notify user that he enter incorrect data to constructor?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You could throw an
ArgumentExceptionor add a contract requiringm > 0or