题目4. 赵斌是一个信管专业的学生,大学四年顺利毕业了。在毕业季,他也像其他学子一样,投身于求职大军,投出一份又一份求职简历,在苦苦地等待之后,他接到了中国移动通信公司广东分司的面试通知书,通知他于本月1号10点到公司面试。当天,晴空万里,艳阳高照,他身着西装,高兴地早早来到公司楼下等待。10点钟整,他和其他新人一起,坐到公司的面试现场。他领取的一一份程序设计题: 假如你是我公司一名客服技术人员,现请你选择自己熟悉的语言,来设计一个程序,管理客户向公司打进来的咨询电话。请事行分析析使用方法和工具,说明自己的思路方法,写一份完整的程序,并实例测试。
#ifndef CLIENT_H
#define CLIENT_H
#include <iostream>
#include <iomanip>
#include <string>
using namespace std;
const int max = 100;
class Client
{
public:
void cclient(string name, float b, long int f, string s);
string Getname(){return name;}
float Getbalance(){return balance;}
long int Getflow(){return flow;}
string Getsetmeal(){return SetMeal;}
void PrintBalance();
void PrintFlow();
void PrintSetMeal();
private:
string name; //姓名
float balance; //余额
long int flow; //流量
string SetMeal; //套餐
};
void Client:: cclient(string name, float b, long int f, string s)
{
this->name = name;
balance = b;
flow = f;
SetMeal = s;
}
void Client::PrintBalance()
{
cout << "您好,您的余额(元):" << balance <<endl;
}
void Client::PrintFlow()
{
cout << "您好,您的剩余流量(M):" << flow <<endl;
}
void Client::PrintSetMeal()
{
cout << "您好,您的已有套餐如下:" << endl;
cout << SetMeal << endl;
cout << endl;
}
double balance1[6] = {32.0, 55.3, 62.4, 20.3, 0, 19.5};
long int flow1[6] = {200, 500, 0, 300, 600, 1024};
string setmeal1 = "10元/月,享受彩铃功能、来电显示";
string setmeal2 = "套餐月功能费用58元,通话时长(国内主叫国内,国际及港澳台长途除外)260分钟,包含国内数据流量30M及来电显示";
string setmeal3 = "套餐月功能费用58元,通话时长(国内主叫国内,国际及港澳台长途除外)260分钟,包含国内数据流量30M及来电显示";
string setmeal4 = "18元 动感地带上网套餐18元 月使用费18元,套餐包含内容:本地主叫本地通话30分钟,短信100条,移动数据流量50MB,本地被叫免费。";
string setmeal5 = "28元 动感地带上网套餐28元 月使用费28元,套餐包含内容:本地主叫本地通话50分钟,短信150条,移动数据流量80MB,本地被叫免费。";
string setmeal6 = "15元 动感地带学习套餐(2012版) 包含 200条网内及网外短信、20MGPRS流量、300分钟高校WLAN时长。";
string name[6] = {"小明","小云","大黄","小王","小连","小兰"};
struct Node
{
Client client;
Node *next;
};
class LinkList
{
public:
LinkList(Client a[],int n);
~LinkList();
void InquiryBalance();
void InquiryFlow();
void InquiryCallRecord();
void InquirySetMeal();
private:
Node *first;
};
LinkList::~LinkList()
{
while(first != NULL)
{
Node *q;
q = first;
first = first->next;
delete q;
}
}
LinkList::LinkList(Client a[],int n)
{
first = new Node;
Node *r,*s;
r = first;
for(int i = 0; i < n; i++)
{
s = new Node;
s->client.cclient(a[i].Getname(),a[i].Getbalance(),a[i].Getflow(),a[i].Getsetmeal());
r->next = s;
r = s;
}
r->next=NULL;
}
void LinkList::InquiryBalance()
{
string x;
cout << "请问您的姓名是?" << endl;
cin >> x;
Node *p = first->next;
while(p!=NULL)
{
if(p->client.Getname() == x)
{
p->client.PrintBalance();
break;
}
p=p->next;
}
if(p == NULL) cout << "无此客户资料!" <<endl;
}
void LinkList::InquiryFlow()
{
string x;
cout << "请问您的姓名是?" << endl;
cin >> x;
Node *p = first->next;
while(p!=NULL)
{
if(p->client.Getname() == x)
{
p->client.PrintFlow();
break;
}
p=p->next;
}
if(p == NULL) cout << "无此客户资料!" <<endl;
}
void LinkList::InquirySetMeal()
{
string x;
cout << "请问您的姓名是?" << endl;
cin >> x;
Node *p = first->next;
while(p!=NULL)
{
if(p->client.Getname() == x)
{
p->client.PrintSetMeal();
break;
}
p=p->next;
}
if(p == NULL) cout << "无此客户资料!" <<endl;
}
#endif
#include "Client.h"
#include <stdlib.h>
void Inquiry(int i);
void menu()
{
cout << setw(50) << "==========================" << endl;
cout << setw(50) << "$ 1.查询余额 $" << endl;
cout << setw(50) << "$ 2.查询剩余流量 $" << endl;
cout << setw(50) << "$ 3.查询已有套餐 $" << endl;
cout << setw(50) << "$ 4.查询最新优惠 $" << endl;
cout << setw(50) << "$ 5.人工服务 $" << endl;
cout << setw(50) << "$ 6.退出 $" << endl;
cout << setw(50) << "==========================" << endl;
}
int main()
{
//把已经存在的客户资料输入在内存里
Client client1;
client1.cclient(name[0], balance1[0], flow1[0], setmeal1 );
Client client2;
client2.cclient(name[1], balance1[1], flow1[1], setmeal2 );
Client client3;
client3.cclient(name[2], balance1[2], flow1[2], setmeal3 );
Client client4;
client4.cclient(name[3], balance1[3], flow1[3], setmeal4 );
Client client5;
client5.cclient(name[4], balance1[4], flow1[4], setmeal5 );
Client client6;
client6.cclient(name[5], balance1[5], flow1[5], setmeal6 );
Client c[6] = {client1, client2, client3, client4, client5, client6};
LinkList l(c, 6);
menu();
char num;
char ch;
cout << "请输入数字1-6" <<endl;
cin >> num;
while(num < '1' || num > '6')
{
cout << "请重新输入!" <<endl;
cin >> num;
}
switch(num)
{
case '1':l.InquiryBalance();break;
case '2':l.InquiryFlow();break;
case '3':l.InquirySetMeal(); break;
case '4':cout << "请移玉步至http://www.10086.cn/gd/" <<endl;
case '5':cout << "请致电10086" << endl;break;
case '6':exit(0);
}
cout << "请问您要继续查询吗?(1:是 其余:不是)" << endl;
cin >> ch;
while(ch == '1')
{
system("cls");
menu();
cin >> num;
while(num < '1' || num > '6')
{
cout << "请重新输入!" <<endl;
cin >> num;
}
switch(num)
{
case '1':l.InquiryBalance();break;
case '2':l.InquiryFlow();break;
case '3':l.InquirySetMeal(); break;
case '4':cout << "请移玉步至http://www.10086.cn/gd/" <<endl;break;
case '5':cout << "请致电10086" << endl;break;
case '6':exit(0);
}
cout << "请问您要继续查询吗?(1:是 其余:不是)" << endl;
cin >> ch;
}
return 0;
}