// CPPTest.cpp : 此檔案包含 "main" 函式。程式執行將在此處開始並結束。
//
#include <iostream>
#include<string>
#include <cctype>
using namespace std;
struct Bop {
string fullname;
string title;
string bopname;
int preference;
};
Bop bops[3] = { { "Wimp Macho","Programmer","Zhouyangzhi",1 }
,{ "Raki Rhodes","Teacher","Xiaopin",2}
,{"Celia Laiter","Doctor","Zhaoyun",1}
};
void ShowMenu();
void DisplayName();
void DisplayTitle();
void DisplayBopName();
void DisplayPer();
int main() {
ShowMenu();
cout << "Enter your choice:";
char ch;
cin >> ch;
switch (ch) {
case 'a':DisplayName();
break;
case'b':DisplayTitle();
break;
case'c':
DisplayBopName();
break;
case'd':
DisplayPer();
break;
case'q':
cout << "Bye!" << endl;
exit(0);
default:
cout << "input a,b,c,d,q:" << endl;
break;
}
cin >> ch;
while ( ch!='q'){
switch (ch) {
case 'a':DisplayName();
break;
case'b':DisplayTitle();
break;
case'c':
DisplayBopName();
break;
case'd':
DisplayPer();
break;
default:
cout << "input a,b,c,d,q." << endl;
break;
}
cout << "Next choice:";
cin >> ch;
}
cout << "Bye." << endl;
}
void ShowMenu() {
cout << "Benevolent Order of Programmers Report" << endl;
cout << "a.display by name\t\t" << "b.display by title" << endl;
cout << "c.display by bopname\t\t" << "d.display by prference" << endl;
cout << "q.quit" << endl;
}
void DisplayName() {
for (int i = 0; i < 3; i++)
cout << bops[i].fullname << endl;
}
void DisplayTitle() {
for (int i = 0; i < 3; i++)
cout << bops[i].title << endl;
}
void DisplayBopName() {
for (int i = 0; i < 3; i++)
cout << bops[i].bopname << endl;
}
void DisplayPer() {
for (int i = 0; i < 3; i++)
cout << bops[i].preference << endl;
}