Phone List Creator via Java
Budget: $10 – $30 USD
Title: Implement a Phone List using a Singly Linked List
Objectives
The goal of this assignment is to design and implement a phone list application
using a singly linked list data structure in Java. You will create a linked list where
each node represents a contact with a person's name and phone number. You are
required to implement the following functionalities: add, display, search, and delete
contacts.
The Problem
You are tasked with developing a phone list that stores contacts using a singly
linked list. Each contact will contain a name and a phone number. You will
implement methods to add new contacts, display all contacts, search for a contact
by name, and delete a contact from the list.
Requirements:
1. Data Structure:
o Implement a class ContactNode to represent a contact. Each ContactNode should contain:
A name (String).
A phone number (String).
A reference to the next ContactNode.
o Implement a class PhoneList that manages the linked list of contacts. It should have a
reference to the head of the list.
2. Methods to Implement:
o addContact(String name, String phoneNumber):
This method should add a new contact at the end of the linked list.
If the list is empty, the new contact should become the first node (head).
If the list is not empty, the method should traverse to the end and add the new contact.
o displayList():
This method should traverse the entire list and print all the contacts.
If the list is empty, it should display an appropriate message.
o searchContact(String name):
This method should search the list for a contact by name.
If the contact is found, it should print the contact's name and phone number.
If the contact is not found, it should display a message indicating that the contact was
not found.
o deleteContact(String name):
This method should delete a contact by name.
If the contact to be deleted is the head, adjust the head to the next node.
If the contact is found elsewhere in the list, remove it by adjusting the pointers of the
surrounding nodes.
If the contact is not found, display a message indicating that no such contact exists.
Expected Output:
The program should display appropriate messages when performing the following operations:
Adding a contact: e.g., "Contact added: Alice, 123-456-7890".
Displaying contacts: e.g., "Name: Alice, Phone: 123-456-7890".
Searching for a contact: e.g., "Contact found: Name: Alice, Phone: 123-456-7890" or "Contact with
name 'Bob' not found."
Deleting a contact: e.g., "Deleting contact: Alice, 123-456-7890" or "Contact with name 'Bob' not
found."
Handling empty lists: e.g., "Phone list is empt
Objectives
The goal of this assignment is to design and implement a phone list application
using a singly linked list data structure in Java. You will create a linked list where
each node represents a contact with a person's name and phone number. You are
required to implement the following functionalities: add, display, search, and delete
contacts.
The Problem
You are tasked with developing a phone list that stores contacts using a singly
linked list. Each contact will contain a name and a phone number. You will
implement methods to add new contacts, display all contacts, search for a contact
by name, and delete a contact from the list.
Requirements:
1. Data Structure:
o Implement a class ContactNode to represent a contact. Each ContactNode should contain:
A name (String).
A phone number (String).
A reference to the next ContactNode.
o Implement a class PhoneList that manages the linked list of contacts. It should have a
reference to the head of the list.
2. Methods to Implement:
o addContact(String name, String phoneNumber):
This method should add a new contact at the end of the linked list.
If the list is empty, the new contact should become the first node (head).
If the list is not empty, the method should traverse to the end and add the new contact.
o displayList():
This method should traverse the entire list and print all the contacts.
If the list is empty, it should display an appropriate message.
o searchContact(String name):
This method should search the list for a contact by name.
If the contact is found, it should print the contact's name and phone number.
If the contact is not found, it should display a message indicating that the contact was
not found.
o deleteContact(String name):
This method should delete a contact by name.
If the contact to be deleted is the head, adjust the head to the next node.
If the contact is found elsewhere in the list, remove it by adjusting the pointers of the
surrounding nodes.
If the contact is not found, display a message indicating that no such contact exists.
Expected Output:
The program should display appropriate messages when performing the following operations:
Adding a contact: e.g., "Contact added: Alice, 123-456-7890".
Displaying contacts: e.g., "Name: Alice, Phone: 123-456-7890".
Searching for a contact: e.g., "Contact found: Name: Alice, Phone: 123-456-7890" or "Contact with
name 'Bob' not found."
Deleting a contact: e.g., "Deleting contact: Alice, 123-456-7890" or "Contact with name 'Bob' not
found."
Handling empty lists: e.g., "Phone list is empt