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

📄 source.h

📁 功能:设计一个飞机订票系统
💻 H
📖 第 1 页 / 共 2 页
字号:
		{
           	cout<<"姓名\t证件号\t航班\t座位号\t订票数量\n";
       		temp->Out();
       		cout<<"\n是否删除(Y/N)";
            cin>>choose;
	        if(choose=='y'||choose=='Y')
			{		        
                while(f)
				{
		           	if(strcmp(f->GetAirline(),airline)==0)
					{						
		           		f->SetAmount(f->GetAmount()+temp->GetAmount()); 
			        	break;
					}
			    	f=f->Next;
				}
				p->Next=temp->Next;
				delete temp;
				cout<<temp->GetAmount()<<endl;
				cout<<f->GetAmount()<<endl;
				cout<<"退票成功:\n";
			}
		   	break;                    
		}
		p=temp;
	    temp=temp->Next; 
	}
    
	Save_Passenger();                                     
	Save_Airline();
	cout<<"1.返回主菜单\n2.继续删除"<<endl;
	cin>>choose;                              
	while(choose!='1'&&choose!='2')
	{
		cout<<"1.返回主菜单\n2.继续退票"<<endl;
	    cin>>choose;
	}
	if(choose=='1')
		Menu();                               
	else if(choose=='2')
		Bounce();                     
}

void Function::Modify()                 //修改函数
{
	char choose,airline[20];               
	Flight *temp,*p;                           
	char start[20];
	char over[20];
	Time starttime;
	Time overtime;
	int money,discount,certain;
	system("cls");
	
	temp=p=Flight_First;
	cout<<"请输入您要修改的航班:";
	cin>>airline;
	while(temp)
	{
		if(strcmp(temp->GetAirline(),airline)==0)          
		{
			cout<<"航班\t起飞地\t抵达地\t起飞时间   抵达时间\t票价\t折扣\t剩余票数\n";
			temp->Out();
			cout<<"\t"<<temp->GetCertain()-temp->GetAmount()<<endl;
        	cout<<"请输入航班:";
         	cin>>airline;                                   
    	    cout<<"请输入起飞地:";
        	cin>>start;                                      
        	cout<<"请输入抵达地:";
        	cin>>over;                                       
        	cout<<"请输入起飞时间(小时):";
            cin>>starttime.hour;
        	cout<<"分钟:";
            cin>>starttime.minutes;
        	cout<<"请输入抵达时间(小时):";
        	cin>>overtime.hour;
        	cout<<"分钟:";
        	cin>>overtime.minutes;
        	cout<<"请输入票价:";
        	cin>>money;
        	cout<<"请输入折扣(%):";
        	cin>>discount;
        	cout<<"请输入载客量:";
        	cin>>certain; 
			temp->Set_Airline(airline,start,over,starttime,overtime,money,discount,certain);
			break;
		}
		temp=temp->Next;                           
	}
	Save_Airline();
	cout<<"修改成功!"<<endl;
	cout<<"1.返回主菜单\n2.继续修改"<<endl;
	cin>>choose;
	while(choose!='1'&&choose!='2')
	{
		cout<<"1.返回主菜单\n2.继续修改"<<endl;
	    cin>>choose;
	}
	if(choose=='1')
		Menu();
	else if(choose=='2')
		Modify();
}


void Function::Read_Flight()                       //读取航班信息函数
{ 
	Flight *p,*p2;
    p=Flight_First;                            
    long t;
    ifstream is("Flight.txt",ios::in);         
    if(!is)                             
	{
		ofstream os("Flight.txt",ios::out);     
        os.close();                        
        return ;
	}
    while(!is.eof())
	{
        p2=new Flight;                   
        p2->Infile(is);
        p->Next=p2;                      
        p2->Next=NULL;                  
         p=p->Next;
	}
}

void Function::Read_Passenger()                       //读取客户信息函数
{ 
	Passenger *p,*p2;
    p=Passenger_First;                            
    ifstream is("Passenger.txt",ios::in);         
    if(!is)                               
	{
		ofstream os("Passenger.txt",ios::out);     
        os.close();                         
        return ;
	}

    while(!is.eof())
	{	
        p2=new Passenger;                   
        p2->Infile(is);                  
        p->Next=p2;                      
        p2->Next=NULL;                   
         p=p->Next;
	}
}

void Function::Save_Passenger()                        //保存客户信息函数
{ 
    ofstream of("Passenger.txt",ios_base::out);        
	Passenger *p=Passenger_First->Next;                       
	while(p)
	{
		p->Ofile(of);                      
		p=p->Next;                       
	}
	of.close();                                    
}

void Function::Save_Airline()                                 //保存航班信息函数
{
	ofstream of("Flight.txt",ios_base::out);         
	Flight *p=Flight_First->Next;                      
	while(p)
	{
		p->Ofile(of);                       
		p=p->Next;                      
	}
	of.close();
}

void Function::Search_Flight()                       
{
	int flag(0);                           
	char choose;                          
	char t1[20],t2[20];                        
	system("cls");
	Flight *temp=Flight_First->Next;            
    do
	{
		cout<<"输入查询方式:\n1.按航班查询\n2.按起飞抵达地查询\n";
		cin>>choose;
		if(choose=='1')
		{
			cout<<"请输入您要查询的航班:";
			cin>>t1;	
			while(temp)
			{
				if(strcmp(t1,temp->GetAirline())==0)        
				{
					flag=1;	
					break;
				}
				temp=temp->Next;         
			}
			if(flag==0)
				cout<<"\n无该航班的信息\n"<<endl;
			else
			{
				cout<<"航班\t起飞地\t抵达地\t起飞时间   抵达时间\t票价\t折扣(%)\t剩余座位\n";
				temp->Out();
				cout<<"\t"<<temp->GetCertain()-temp->GetAmount()<<endl;
			}
			break;
		}
		else if(choose=='2')
		{
			cout<<"请输入您要查询的航班起始地";
			cin>>t1;
			cout<<"请输入您要查询的航班的抵达地:";
			cin>>t2;
			while(temp)
			{
				if(strcmp(t1,temp->GetStart())==0&&strcmp(t2,temp->GetOver())==0)        
				{
					flag=1;		    		
					break;
				}
				temp=temp->Next;         
			}
			if(flag==0)
				cout<<"\n无该航班的信息\n"<<endl;
			else
			{
				cout<<"航班\t起飞地\t抵达地\t起飞时间   抵达时间\t票价\t折扣(%)\t剩余座位\n";
				temp->Out();
				cout<<"\t"<<temp->GetCertain()-temp->GetAmount()<<endl;         
			}
			break;
		}
	}while(choose!='1'||choose!='2');

	cout<<"\n1.返回主菜单\n2.继续查询"<<endl;
	cin>>choose;
	while(choose!='1'&&choose!='2')
	{	
		cout<<"1.返回主菜单\n2.继续查询"<<endl;
		cin>>choose;
	}
	if(choose=='1')
		Menu();               
	else if(choose=='2')
     	Search_Flight();           	
}

void Function::Show_Flight()        
{
	char choose;
	Flight *temp;
	system("cls");
	temp=Flight_First->Next;         
	if(!temp)                  
	{
		cout<<"文件无数据\n\n "<<endl;
		cout<<"1.返回主菜单"<<endl;
	    cin>>choose;
	     while(choose!='1')
		 {
			 cout<<"1.返回主菜单"<<endl;
	         cin>>choose;
		 }
    	Menu();           
	}
	else
	{ 
		cout<<"航班\t起飞地\t抵达地\t起飞时间   抵达时间\t票价\t折扣\t剩余票数\n";
		while(temp!=NULL)
		{
			temp->Out();
			cout<<"\t"<<temp->GetCertain()-temp->GetAmount()<<endl;
    		temp=temp->Next;     				
		}
	}
	cout<<"1.返回主菜单"<<endl;
	cin>>choose;
	while(choose!='1')
	{
		cout<<"1.返回主菜单"<<endl;
	    cin>>choose;
	}
	Menu();                      
}

void Function::Show_Passenger()        
{
	char choose;
	Passenger *temp;
	system("cls");
	temp=Passenger_First->Next;         
	if(!temp)                  
	{
		cout<<"文件无数据\n\n "<<endl;
		cout<<"1.返回主菜单"<<endl;
	    cin>>choose;
	     while(choose!='1')
		 {
			 cout<<"1.返回主菜单"<<endl;
	         cin>>choose;
		 }
    	Menu();           
	}
	else
	{ 
		cout<<"姓名\t证件号\t座位\t航班\t订票数量\n";
		while(temp!=NULL)
		{
			temp->Out();        
		    cout<<endl;
    		temp=temp->Next;     				
		}
	}
	cout<<"1.返回主菜单"<<endl;
	cin>>choose;
	while(choose!='1')
	{
		cout<<"1.返回主菜单"<<endl;
	    cin>>choose;
	}
	Menu();                      
}

void Function::Menu()
{
	char choose;               
	system("cls");
	cout<<"    ========================================================================"<<endl;
	cout<<"                    欢 迎 使 用 该 东 航 订 票 系 统"<<endl;
	cout<<"    ========================================================================"<<endl;
	cout<<"\n";
	cout<<endl;
	cout<<"        1 录入航班信息:\n"<<endl;
	cout<<"        2 查询航班信息:\n"<<endl;
	cout<<"        3 订票:\n"<<endl;
	cout<<"        4 退票:\n"<<endl;
	cout<<"        5 修改航班信息:\n"<<endl;
	cout<<"        6 显示全部航班信息:\n"<<endl;
	cout<<"        7 显示全部客户信息:\n"<<endl;
	cout<<"        8 退出系统"<<endl;
	cout<<endl;
	cout<<"请选择需要提供的服务类型(1,2,3,4,5,6):"<<endl;
	cin>>choose;
	switch(choose)
	{
	case '1': Add_Airline();break;                 
	case '2': Search_Flight();break;
	case '3': Book();break;
	case '4': Bounce();break;
	case '5': Modify();break;
	case '6': Show_Flight();break;
	case '7': Show_Passenger();break;
	case '8': exit(1);break;	
	default:
		{
			cout<<"请按规定输入选择项!"<<endl;
			Menu();
		}
	}
}
           
void main()
{
	Function function;          //定义功能接口
	function.Menu();            //调用主菜单
}

⌨️ 快捷键说明

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