Q020 - Contact Details Validation Exception

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

Contact Details Validation Exception

Mr. Khan operates a big shopping complex in Alice City where customers can buy products for
their daily needs. Multiple sales executives are employed at this shopping complex for
inventory tracking and customer service.
Due to a staff shortage, the shopping complex's management started hiring new employees,
and in the first round, they took a person's basic details online.
While filling in the details, a person must ensure that the data entered is unique and without
duplication. The applicants must enter their name, address, email, mobile number, and
alternate mobile number.
Note: An exception error message should be displayed if the mobile and alternate numbers
match.

Override ToSting() to display the details

[Note : Strictly adhere to the object-oriented specifications given as a part of the problem
statement.
Follow the naming conventions as mentioned. Create separate classes in separate files.]

Consider a class called ContactDetails with the following protected member variables

Data Type Attributes


string name
string address
string email
long mobileNo
long alternateNo

Include appropriate getters and setters.


Include default and parameterized constructor for the class.
Prototype for the Parameterized Constructor ContactDetails(string _name,string
_address,string _email,long _mobileNo,long _alternateNo)

And also override ToString() methods to display the contact details of applicant.

Consider another class called ValidateContactDetails with the following method


Sno Method name Method description
1 void Validate() This method is used to check Mobile No and
Alternate No , in case both matches it will throw an
exception by providing the message “Mobile
number and alternate number should not be
same” other wise ToString() method should be
invoked to display the details.
Consider another class called DuplicateNumberException which should
extends Exception class
Consider class Program with Main method to get the contact details of the applicant and
validate their details by calling Validate() method of ValidateContactDetails class
The link to download the template code is given below
Code Template

Input and Output Format:

Refer sample input and output for formatting specifications.

[All text in bold corresponds to the input and the rest corresponds to output.]

Sample Input and Output 1:


Enter the contact details(name,present address,email,mobile number,alternate number)
Tahura Begum,House No 53 street lane Pune
India,[email protected],9987654312,9987654316

ContactDetail [name=Tahura Begum, address=House No 53 street lane Pune India,


[email protected], mobileNumber=9987654312,
alternateMobileNumber=9987654316]

You might also like