Create a console application that manages personal and professional contacts with data validation and search capabilities.
class Contact {
public string FirstName { get; set; }
public string LastName { get; set; }
public string PhoneNumber { get; set; }
public string Email { get; set; }
public DateTime Birthday { get; set; }
public ContactType Type { get; set; } // Personal or Professional
}
enum ContactType {
Personal,
Professional
}
a) Contact Creation
- Prompt user for all contact fields
- Implement the following validations:
- Names: 2-50 characters, letters only
- Phone: Format (XXX) XXX-XXXX or XXX-XXX-XXXX
- Email: Must contain @ and valid domain (.com, .org, etc.)
- Birthday: Cannot be future date, must be > 18 years old
- Must confirm data before saving
b) Contact Display
- Show all contacts in formatted table
- Include columns: Full Name, Phone, Email, Age, Type
- Sort options:
- Alphabetical by last name
- By age (youngest/oldest)
- By type
c) Search Functionality
- Search by partial name match
- Search by age range
- Search by contact type
- Display "No matches found" when appropriate
d) Data Management
- Store minimum of 5 contacts
- Allow contact deletion
- Allow contact information updates
- Prevent duplicate email addresses
- Clear menu system (1-Display, 2-Add, 3-Search, 4-Update, 5-Delete, 6-Exit)
- Input validation messages
- Confirmation messages for actions
- Error messages must be descriptive
- Option to return to main menu from any point
Implement try-catch blocks for:
- Invalid data entry
- Search with no results
- Update/delete of non-existent contact
- Invalid menu selection
=== Contact Management System ===
1. Display All Contacts
2. Add New Contact
3. Search Contacts
4. Update Contact
5. Delete Contact
6. Exit
Enter your choice (1-6): 2
=== Add New Contact ===
Enter First Name: John
Enter Last Name: Smith
Enter Phone ((XXX) XXX-XXXX): (555) 123-4567
Enter Email: [email protected]
Enter Birthday (MM/DD/YYYY): 01/15/1980
Select Type (1-Personal, 2-Professional): 1
Contact Summary:
Name: John Smith
Phone: (555) 123-4567
Email: [email protected]
Age: 44
Type: Personal
Save contact? (Y/N): Y
Contact saved successfully!
- Proper class design
- Clear method organization
- Consistent naming conventions
- Appropriate comments
- Code reusability
- All input fields properly validated
- Appropriate error messages
- Proper exception handling
- Edge cases handled
- All required features working
- Correct calculations
- Proper data storage
- Efficient search implementation
- Clear menu system
- Informative messages
- Logical program flow
- Error recovery