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

📄 customer.cpp

📁 用于航空订票系统中客户信息管理的类
💻 CPP
字号:
#include <cstdlib>
#include <iostream>

using namespace std;

class Person 
{
private:
        
    int id;
    string name;
    string password;
    string flightnum;
    int seatnum;

public:
       
    Person()
    {
        id = -1;
        name = "";
        password = "";
        flightnum = "";
        seatnum = -1;
    } 
    
    int getId() 
    {
        return id;
    }
    
    void setId(int i) 
    {
        id = i;
    }
    
    string getName() 
    {
        return name;
    }
    
    void setName(string n) 
    {
        name = n;
    }
    
    string getPassword() 
    {
        return password;
    }
    
    void setPassword(string p) 
    {
        password = p;
    }
    
    string getflightnum() 
    {
        return flightnum;
    }
    
    void setflightnum(string f) 
    {
        flightnum = f;
    }
    
    int getseatnum() 
    {
        return seatnum;
    }
    
    void setseatnum(int s) 
    {
        seatnum = s;
    }
};



class Customer : public Person
{
public: 
            
    Person customer[1000];
        
    Customer()
    {
        Person();
    }
       
    Person getcustomeri(int i)//顾客信息 
    {
        return customer[i];       
    }

    int j;    
    int creatcustomer() //创建顾客
    {

        for(j = 0;j<1000;j++)
        {
            if(getcustomeri(j).getId() == -1)
            {
                break;
                cout<<"j:"<<j<<endl; //测试用 
                return j; 
            }
        }

         
    }    

    
    void deletecustomer(int id2)//删除顾客
    {
        int i = id2;
        customer[i].setId(-1);
        customer[i].setName("");
        customer[i].setPassword("");
        customer[i].setflightnum("");
        customer[i].setseatnum(-1);            
    }
    
    string printcustomer(int id3)//显示顾客信息
    {
        int i = id3;
        cout<<"customerid:"<<customer[i].getId()<<endl;
        cout<<"customername:"<<customer[i].getName()<<endl;
        cout<<"customerpassword:"<<customer[i].getPassword()<<endl;
        cout<<"customerflightnum:"<<customer[i].getflightnum()<<endl;
        cout<<"customerseatnum:"<<customer[i].getseatnum()<<endl;           
    }
    
    void getticket(int id4)//顾客订票
    {        
        int i = id4;
        string flightnum4;
        int seatnum4;
        /*调用航班类的函数,返回航班号和座位号*/
        customer[i].setflightnum(flightnum4);
        customer[i].setseatnum(seatnum4);                 
    }

    void deleteticket(int id5)//顾客退票
    {
        int i = id5;
        customer[i].setflightnum("");
        customer[i].setseatnum(-1);        
    }
            	
};


Customer c;
int i;
int main(void)
{

    c.customer[0].setId(0);
    cout<<"customer[0]的id:"<<c.getcustomeri(0).getId()<<endl;
    
    i = c.creatcustomer();
    
    /*下面的写成函数*/         
    string name1 ;
    string password1 ;
    cout<<"请输入姓名和密码:"<<endl;        
    cin>>name1>>password1; 
      
    c.customer[i].setId(i);
    c.customer[i].setName(name1);
    c.customer[i].setPassword(password1);
    
    cout<<"customer[i]的name:"<<c.getcustomeri(i).getName()<<endl;
    cout<<"customer[i]的id:"<<c.getcustomeri(i).getId()<<endl;
    cout<<"customer[i]的password:"<<c.getcustomeri(i).getPassword()<<endl;
    
    system("PAUSE");
    return 0;
}






⌨️ 快捷键说明

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