c customer database
Assume that you are running a business where customers come and buy your products from your shopping store. So you need to create a database which maintains a list of all of your customers and whatever each customer bought from your store.
You should create two classes, one for Customer and the other for Product.
A Customer should have at least the following parameters: (Please note that you may add additional parameters of your choice for each customer if it helps you in any way)
First Name: string
Last Name: string
Customer type:string, Note that this parameter defines the type of customer based on the following conditions:
if this customer has purchased items worth less than $100, his types is “normal”
else if this customer has purchased items worth less than $1000, his types is “good”
else if this customer has purchased items worth more than $1000, his types is “excellent”
items: Product * (this field is of type Product pointer which points to the object of type Product)
next: Customer* (this pointer will point to the next customer in the list)
A Product should have at least the following parameters: (Please note that you may add additional parameters of your choice in this class if it helps you in any way)
Name of product: string
Price of this product: double
next: Product* (this pointer will point to the next product in the list)
You should create a pointer, say CustomerDatabase, as the head of the database which points to the first customer in the linked list.
Customer * CustomerDatabase = NULL; //this pointer is the head of the linked list. Don’t call it head.
You should provide functions to support the following operations:
1. Add a new customer in the list (take input from user, all the fields and add a new customer)
2. Delete a customer from the list (based on customer’s first name). Notice that deleting a customer should delete all the products that the customer bought so far.
3. Add a product as in the list of currently bought products of a customer (by customer’s first name). You should ask two things, the first name of the customer to know which customer is buying something, and the product information to add that product in the list of products of this particular customer.
4. Delete a product from the list of products of a customer. You should ask first customer’s first name and then product name in order to delete it from the list.
5. Print all the customers along with their list of products in the entire list.
6. Delete all the products of a particular customer (by customer’s first name).
7. Delete all the customers from the list. This includes deleting all the products of each customer..
The following diagram shows how the linked list should look like. Please note about the following diagram of linked list: (Also note that the dotted line arrows in the following diagram are comments)
1) CustomerDatabase is the name of the head of the linked list that contains all of your customers (shown as the first row of list).
2) Each Node represents a customer which contains all the fields mentioned above including:
a) one pointer “next” that points to the next customer in the list (shown by an arrow on
the right hand side of each node on the first line).
b) one pointer “items” (shown by an arrow in the bottom of each node) which
points to the linked list containing the list of items bought by this customer.
3) In this diagram, each node only mentions first name of the customer. However, it also contains other fields as mentioned above, but that is not shown in the diagram to keep it simple.
These are “next” pointers pointing at object type “customer”
assignment Output Screen:
When I run the assignment, it should look like the following:
Please select any item from the following menu:
1: Add a new customer in the list
2: Delete a customer from the list
3: Add a product in the list of currently bought products of a customer
4: Delete a product from the list of products of a customer.
5: Print all the customers along with their list of products
6: Delete all the products of a particular customer
7: Delete all the customers from the list.
Ø (here I will type a number from the above menu)
Now, after I see the above menu, I will make a selection from 1 to 10. Based on my selection, your program should call some function to carry out the operation needed for that selected task.
After that operation is performed, you should show me the above mentioned selection menu again. This should continue in an infinite loop until I want to exit the program.