⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 custlisttype.cpp

📁 光盘出租管理系统
💻 CPP
字号:
#include <iostream.h>
#include "custListType.h"

void custListType::custSearch(newString id)
{
	nodeType<custType>* current;
	if(first == NULL)
		cout<<"Cannot search a customer in an empty List!"<<endl;
	else
	{
		current = first;
		while(current != NULL)
		{
			if(current->info.checkcustAcctNo(id))
			{
				cout<<"在顾客库中找到";
				current->info.printcustInfo();              //找到并打印
				break;
			}
			else
			{
				current = current->link;
			}			
		}
		if(current == NULL)
			cout<<id<<"还没有注册成为本店会员,欢迎加入!"<<endl<<endl;
	}
}

bool custListType::seachAcctNo(newString acctno)           //为插入新顾客服务,以防帐号已经存在
{   bool found = false;
	nodeType<custType>* location;
	searchCustList(acctno,found,location);
	return found;
}

void custListType::insertcust()
{
    custType customer;
	newString acctno;
	newString fname;
	newString lname;
	cout<<"请输入帐号:";
	cin>>acctno;
	while(seachAcctNo(acctno))                             //用到了上面的seachAccNo函数!!!
	{
		cout<<"你所输入的帐号已经存在,请重新输入!";
		cout<<"请输入帐号:";
		cin>>acctno;
	}

	cout<<"请输入名字:";
	cin>>fname;
	cout<<"请输入姓氏:";
	cin>>lname;
	customer.setCustInfo(acctno,fname,lname," "," "," ");
	insertFirst(customer);
}

void custListType::deletcust(newString acctno)
{
	nodeType<custType>* current;                           //指向当前节点的指针    
	nodeType<custType>* trailCurrent;                      //指向当前节点的前一个指针
	bool found;

	if(first == NULL)
		cout<<"Cannot delete from an empty custList.\n";
	else
	{
		if(first->info.checkcustAcctNo(acctno))
		{
			current = first;
			first = first->link;
			if(first ==NULL)
				last = NULL;
			delete current;
		}
		else
		{
			found = false;
			trailCurrent = first;
			current = first->link;
			while((!found) && (current !=NULL))
			{
				if(!current->info.checkcustAcctNo(acctno))
				{
					trailCurrent = current;
					current = current->link;
				}
				else
					found = true;
			}
			if(found)
			{
				trailCurrent->link = current->link;
				if(last == current)                    //last->info = deleteItem
					last = trailCurrent;
				delete current;
				cout<<"已经成功删除顾客!"<<endl;
			}
			else
				cout<<"Item to be deleted is not in the list."<<endl;
		} //end else
	} 
}

void custListType::PrintAllInfo()
{
	nodeType<custType>* current;
	current = first;
	while(current != NULL)
	{
		current->info.printcustInfo();
		current = current->link;
	}
}

void custListType::searchCustList(newString AcctNo,bool& found,nodeType<custType>* &current)
{
	found = false;
	if(first == NULL)
		cout<<"Cannot search an empty custlist."<<endl;
	else
	{
		current = first;	    
		while(!found && current !=NULL)
		{
			if(current->info.checkcustAcctNo(AcctNo))
				found = true;
			else
				current = current->link;
		}
	}
}


void custListType::custrentvideo(newString AcctNo,newString title )
{   bool found;
	nodeType<custType>* location;
	searchCustList(AcctNo,found,location);
	if(found)
		location->info.rentVideo(title);
	else
		cout<<"不能租碟。"<<endl;

}

void custListType::custbackvideo(newString AcctNo,newString title)
{	bool found;
	nodeType<custType>* location;
	searchCustList(AcctNo,found,location);
	if(found)
	
		location->info.backVideo(title)	;
	
	
	else
		cout<<"不能还碟。";
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -