c + + "management system design of hair salon"

Posted by thiscatis on Sun, 14 Jun 2020 05:22:27 +0200

Design of hairdressing shop management system

1. Problem description
Define the customer category. The attributes include: membership card number, name, gender, phone number and other information, as well as related behaviors of operating attributes.
Define employee category: attributes include: number, name, gender, phone number, hairdressing items (barber, perm, shampoo) and other information, as well as related behaviors to operate attributes.
Define hairdressing class: the attribute has the charging standard of various hairdressing items and the related behavior of operating on the attribute.

2. Functional requirements
(1) Hairdressing function. According to the hairdressing items, service employees, consumption amount and so on, the corresponding information will be added to the information of designated customers in the customer category and designated employees in the employee category.
(2) Simple management function.
Add function: the program can add customer information and employee information, and the number is required to be unique. If a record with duplicate number is added, it will prompt data to add duplicate and cancel adding.
Query function: the added customer information can be queried according to the name, phone number, card number and other information. If it is not found, the corresponding prompt information will be given. If it is found, the corresponding record information will be displayed. The employee information can also be queried according to the name, work type number and other information.
Display function: it can display all customer information and employee information in the current system, each information occupies one line.
Edit function: the corresponding records can be modified according to the query results. Pay attention to the uniqueness of the number when modifying.
Deletion function: mainly to delete the added customer and employee records. If there is no corresponding personnel record in the current system, the prompt "record is empty!" And return to the operation.
Save function: the customer and employee records in the current system can be saved in any way. Read function: the information saved in the file can be read into the current system for users to use.
(3) Statistical function. Be able to count the total consumption of customers and the total income of employees. They are sorted from large to small.
3. The solution to the problem can be divided into the following steps according to the functional requirements of the system:
(1) Application system analysis, the establishment of the system functional block diagram and interface organization and design;
(2) Analyze the entities in the system and their relationships;
(3) According to the problem description, the class level of the system is designed;
(4) Complete the description of each class in the class level;
(5) Complete the definition of each member function in the class;
(6) Complete the application module of the system;
(7) Function debugging;
(8) Complete the system summary report.

1, General design

1.1 composition of main menu

There are 6 options in the main menu: manage customers, manage employees, manage hairdressing items, hairdressing functions, statistics functions, exit the system

1.2 function of submenu

The three management submenus have six options: display information, add information, delete information, query information, save information, and return.

2, Detailed design

2.1 procedure flow chart

(1) Data flow graph
Data flow diagram is a description of the data flow direction of the system, and in essence, it allows users of the program to roughly understand the use method of the system. The general flow chart of the management system is as follows:

(2) System flow chart

The system flow chart describes the general flow of the system. The system flow chart of the system is as follows:

2.2 detailed design of program module
2.2.1 main menu
With the help of switch statement, we can choose the next step;

2.2.2 management submenu

It can read and write data, display, add, delete, search and modify data through linked list;

Take the customer management submenu interface as an example:

2.2.3 hairdressing function
Add the corresponding information to the information of the designated customer and the designated employee in the customer category according to the hairdressing project number, employee number of the service, consumption amount, etc
2.2.4 statistical function
With the help of vector container, the data is read from the text file and sorted, and the total consumption of customers and the total income of employees are calculated. They are sorted from large to small.
3, Design core technology realization
3.1 read data (take customer class as an example)

node* ReadData()//Read text data as a linked list
 {
  m = 0;
  node* head = NULL;
  FILE* fp;
  fp = fopen("Customer.txt", "r");
  p1 = p2 = new node;
  head = NULL;
  while (!feof(fp))//When not to the end of the file
  {
   m++;
   fscanf(fp, "%d %s %s %s %d\n", &p1->Id, &p1->Name, &p1->Sex, &p1->Phone,&p1->Money);//fscanf() reads from the stream in format 
   if (m == 1)
    head = p1;
   else
    p2->next = p1;
   p2 = p1;
   p1 = new node;
  }
  p2->next = NULL;
  fclose(fp);
  return head;
 }

3.2 display data (take customer as an example)

//Output function outputs linked list data 
 int  print(node* head)
 {
  cout << "Card number, name, gender, telephone cumulative consumption" << endl
   << "**********************************************************\n";
  if (m == 1)
  {
   cout << "No customers" << endl;
   return 0;
  }
  node* p;
  p = head->next;
  while (p != NULL)
  {
   cout << p->Id << " " << p->Name << " " << p->Sex << " " << p->Phone << " " << p->Money<<endl;
   p = p->next;
  }
  system("PAUSE");//Pause the execution of the program and wait for any key to continue
 }

3.3 add data (take customer as an example)

               bool Findnode(node* head, int key)//Find whether there is a user with Id as key
 {
  node* ptr = head;
  while (ptr != NULL && ptr->Id != key)
  {
   ptr = ptr->next;
  }
  if (ptr != NULL)
  {
   
   return 0;
  }
  else
  {
   return 1;
  }
 }
 //Add function add data after linked list
 void  creat(node* head)
 {
  cout << "Please input a customer information: please save after input (Note: card number is only a number)" << endl
   << "Card number name gender phone" << endl
   << "**********************************************************\n";
  cin >> p1->Id >> p1->Name >> p1->Sex >> p1->Phone;
  while (cin.fail())
  {
   cin.clear();
   cin.ignore();
   cout << "Input error, please input again" << endl;
   cin >> p1->Id >> p1->Name >> p1->Sex >> p1->Phone;
  }
  p1->Money = 0;
  if (Findnode(head, p1->Id) == 0)
  {
  printf("Card number add duplicate cancelled");
  
  }
  if (Findnode(head, p1->Id) == 1)
  {
  m = m + 1;
   p2->next = p1;
   p2 = p1;
   p1 = new node;
   p2->next = NULL;
  }
 }

3.4 delete data (take customer as an example)

//Delete function delete specified node in linked list 
	int Delete(node* head)
	{

		int num;
		cout << "Please input the card number to be deleted: please save after input (Note: card number is only a number)" << endl;
		cin >> num;
		while (cin.fail())
		{
			cin.clear();
			cin.ignore();
			cout << "Input error, please input again" << endl;
			cin >> num;
		}
		if (Findnode(head, num) == 1)
		{
			cout << "Record is empty!" << endl;
			return 0;
		}
		node* p3, * p4, * t;
		p3 = head;
		if (p3->Id == num)
		{
			t = head;
			head = t->next;
		}
		p4 = p3;
		p3 = p3->next;
		while (p3 != NULL)
		{
			if (p3->Id == num)
			{
				p4->next = p3->next;
				return 0;
			}
			p4 = p3;
			p3 = p3->next;
		}
	}

3.5 search and modify data (take customer class as an example)

//Query function query specified node
	int Find(node* head)
	{
		cout << "Please select query method:Enter 0 or 1 or 2" << endl;
		cout << "Query by customer card number (0); query by customer name (1); query by customer phone (2)" << endl;
		int a;
		cin >> a;
		while (cin.fail())
		{
			cin.clear();
			cin.ignore();
			cout << "Input error, please input again" << endl;
			cin >>a;
		}
		node* ptr = head->next;
		if (a == 0)
		{
			int num;
			
			cout << "Please enter the customer card number to be queried (Note: card number is only a number)" << endl;
			cin>>num;
			while (cin.fail())
			{
				cin.clear();
				cin.ignore();
				cout << "Input error, please input again" << endl;
				cin >> num;
			}
			while (ptr != NULL && ptr->Id != num)
			{
				ptr = ptr->next;
			}
		}
		else if (a == 1)
		{
			char name[15];
			cout << "Please enter the name of the customer to query" << endl;
			cin >> name;
			while (ptr != NULL && strcmp(ptr->Name , name)!=0)
			{
				ptr = ptr->next;
			}
		}
		else if (a == 2)
		{
			char phone[15];
			cout << "Please enter the phone number of the customer to be inquired" << endl;
			cin >> phone;
			while (ptr != NULL && strcmp(ptr->Phone , phone)!=0)
			{
				ptr = ptr->next;
			}
		}
		else 
		{
			cout << "error" << endl;
			return 0;
		}
			if (ptr == NULL)
			{
				printf("The customer was not found");
				return 0;
			}
			else
			{
				cout << "Card number, name, gender, telephone cumulative consumption (yuan)" << endl
					<< "**********************************************************\n";
				cout << ptr->Id << " " << ptr->Name << " " << ptr->Sex << " " << ptr->Phone << " " << ptr->Money << endl;
			}
		
			printf("Do you want to modify the information: Please enter 1(modify)Or 0(Back to previous screen)\n");
			int n;
			cin >> n;
			while (cin.fail())
			{
				cin.clear();
				cin.ignore();
				cout << "Input error, please input again" << endl;
				cin >> n;
			}
			if (n)
			{
				cout <<"Please enter the modified information (Note: cumulative consumption is only a number)" << endl
					<< "Name Gender telephone cumulative consumption (yuan)" << endl
					<< "**********************************************************\n";
				cin >>  ptr->Name >> ptr->Sex >> ptr->Phone>> ptr->Money;
				while (cin.fail())
				{
					cin.clear();
					cin.ignore();
					cout << "Input error, please input again" << endl;
					cin >> ptr->Name >> ptr->Sex >> ptr->Phone >> ptr->Money;
				}
				return 0;
			}
	
		
	}

3.6 save data (take customer as an example)

//Save save linked list data to text
	int  WriteData(node* head)
	{
		FILE* fp;
		node* p;
		fp = fopen("Customer.txt", "w");
		p = head;
		while (p != NULL)
		{
			fprintf(fp, "%d %s %s %s %d\n", p->Id, p->Name, p->Sex, p->Phone,p->Money);
			//Output to stream in format
			p = p->next;
		}
		fprintf(fp, "\0");
		rewind(fp);//Return the current read / write location to the beginning of the file
		cout << "Saved successfully!";
		fclose(fp);//Close file
		return 0;
	}

3.7 hairdressing function

//Hairdressing function
void hair()
{
	cout << "Please enter the customer card number (Note: card number is only a number)" << endl;
	int a, b, c;
	cin >> a;
	while (cin.fail())
	{
		cin.clear();
		cin.ignore();
		cout << "Input error, please input again" << endl;
		cin >> a;
	}
	Customer a1;
	Customer::node* head1=a1.ReadData(),*ptr1;
	ptr1 = head1->next;
	while (ptr1 != NULL && a != ptr1->Id)
	{
		ptr1 = ptr1->next;
	}
	if (ptr1 == NULL)
	{
		printf("The user does not exist");
		menu();
	}
	else
	{
		cout << "Card number, name, gender, telephone cumulative consumption (yuan)" << endl;
		cout << ptr1->Id << " " << ptr1->Name << " " << ptr1->Sex << " " << ptr1->Phone << " " << ptr1->Money << endl;
		cout << "Please enter employee number" << endl;
		cin >> b;
		while (cin.fail())
		{
			cin.clear();
			cin.ignore();
			cout << "Input error, please input again" << endl;
			cin >> b;
		}
		Worker b1;
		Worker::node* head2 = b1.ReadData(),*ptr2;
		ptr2 = head2->next;
		while (ptr2 != NULL && b != ptr2->Id)
		{
			ptr2 = ptr2->next;
		}
		if (ptr2 == NULL)
		{
			printf("The employee does not exist");
			menu();
		}
		else
		{
			cout << "No. Name Gender total telephone revenue (yuan)" << endl;
			cout << ptr2->Id << " " << ptr2->Name << " " << ptr2->Sex << " " << ptr2->Phone << " " << ptr2->Money << endl;
			cout << "Please input the hairdressing project number made by the customer" << endl;
			cin >> c;
			while (cin.fail())
			{
				cin.clear();
				cin.ignore();
				cout << "Input error, please input again" << endl;
				cin >> c;
			}
			Item c1;
			Item::node* head3 = c1.ReadData(), * ptr3;
			ptr3 = head3->next;
			while (ptr3 != NULL && b != ptr3->Id)
			{
				ptr3 = ptr3->next;
			}
			if (ptr3 == NULL)
			{
				printf("The hairdressing project does not exist");
				menu();
			}
			else
			{
				cout << "Item No    Price (yuan)" << endl;
				cout << ptr3->Id << " " << ptr3->item << " " << ptr3->Price << endl;
				ptr1->Money += ptr3->Price;
				ptr2->Money += ptr3->Price;
				cout << "**********************************************************\n"<<"Data after hairdressing" << endl;
				cout << "Customer card number name gender telephone cumulative consumption (yuan)" << endl;
				cout << ptr1->Id << " " << ptr1->Name << " " << ptr1->Sex << " " << ptr1->Phone << " " << ptr1->Money << endl;
				cout << "Employee no. Name Gender total telephone revenue (yuan)" << endl;
				cout << ptr2->Id << " " << ptr2->Name << " " << ptr2->Sex << " " << ptr2->Phone << " " << ptr2->Money << endl;
				a1.WriteData(head1);
				b1.WriteData(head2);
			}
		}
	}
	menu();
}

3.8 statistical function

//Statistical function
struct node
{
	int Id;//number
	char Name[15];//full name
	char Sex[4];//Gender
	char Phone[15];//phone number
	int Money;
};
bool cmp(node a, node b) 
{
	return a.Money > b.Money;
}
void Sort()
{
	cout << "Please enter 0 (customer Statistics) or 1 (employee Statistics)"<<endl;
	bool x;
	cin >> x;
	while (cin.fail())
	{
		cin.clear();
		cin.ignore();
		cout << "Input error, please input again" << endl;
		cin >> x;
	}
	vector<node> a;
	node  c;
	FILE* fp;
	if (x == 0)
	{
		cout << "Customer card number name gender total telephone consumption" << endl
			<< "**********************************************************\n";
		fp = fopen("Customer.txt", "r");
	}
	else if(x == 1)
	{
		cout << "Employee number name gender total phone revenue" << endl
			<< "**********************************************************\n";
		fp = fopen("Worker.txt", "r");
	}
	else
	{
		cout << "error"<<endl;
		Sort();
	}
	bool f = 0;
	while (!feof(fp))//When not to the end of the file
	{
		fscanf(fp, "%d %s %s %s %d\n", &c.Id,&c.Name, &c.Sex, &c.Phone, &c.Money);//fscanf() reads from the stream in format 
		if (f)
		{
			a.push_back(c);
		}
		f = 1;
	}
	sort(a.begin(), a.end(),cmp);
	int i = a.size();
	for (vector<node>::iterator it = a.begin(); it != a.end(); it++)
	{
		cout << it->Id << " " << it->Name << " " << it->Sex << " " << it->Phone << " " << it->Money << endl;
		
	}
	menu();
}

3.9 judge whether the input is correct (take int data as an example)

int num;    
	cin >> num;	
	while(cin.fail())//If the status of cin is judged, 1 will be returned if the cin is in error status, and 0 will be returned if the cin is in normal status
	{
		cin.clear();//Clear error status of cin
		cin.ignore();//Ignore buffer contents until EOF is encountered
		cout << "Input error, please input again"<<endl;
		cin >> num;
	}

Design of c + + hairdressing shop management system.zip (including project report)

Topics: P4 Attribute