Skip to content

Instantly share code, notes, and snippets.

@jeroos
Created October 30, 2024 04:07
Show Gist options
  • Save jeroos/e9d1a4944b2ecdb0ddf00ccb66f91fd3 to your computer and use it in GitHub Desktop.
Save jeroos/e9d1a4944b2ecdb0ddf00ccb66f91fd3 to your computer and use it in GitHub Desktop.

Contact Management System

Objective

Create a console application that manages personal and professional contacts with data validation and search capabilities.

Technical Requirements

1. Data Structure

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
}

2. Required Functionality

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

3. User Interface Requirements

  • 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

4. Error Handling

Implement try-catch blocks for:

  • Invalid data entry
  • Search with no results
  • Update/delete of non-existent contact
  • Invalid menu selection

Sample Interaction

=== 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!

Evaluation Criteria

1. Code Structure (30%)

  • Proper class design
  • Clear method organization
  • Consistent naming conventions
  • Appropriate comments
  • Code reusability

2. Data Validation (25%)

  • All input fields properly validated
  • Appropriate error messages
  • Proper exception handling
  • Edge cases handled

3. Functionality (25%)

  • All required features working
  • Correct calculations
  • Proper data storage
  • Efficient search implementation

4. User Experience (20%)

  • Clear menu system
  • Informative messages
  • Logical program flow
  • Error recovery
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment