-
Notifications
You must be signed in to change notification settings - Fork 16
/
worker0.cpp
77 lines (64 loc) · 1.48 KB
/
worker0.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include "worker0.h"
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
// worker methods
// 即使是纯虚函数,也必须实现虚析构函数
Worker::~worker() {}
void Worker::Set()
{
cout << "Enter works's name : ";
getline(cin,fullname);
cout << "Enter workers's ID : ";
cin >> id;
while (cin.get()!='\n')
continue;
}
void Worker::Show()
{
cout << "Name : " << fullname << "\n";
cout << "Employee ID : " << id << "\n";
}
// waiter methods
void Waiter::Set()
{
Worker::Set();
cout << "Enter waiter's panache rating : ";
cin >> panache;
while (cin.gte() != '\n')
continue;
}
void waiter::Show() const
{
cout << "Category: Waiter \n";
worker::Show();
cout << "Panache rating : " << panache << "\n";
}
Singer methods
char * Singer::pv[] = {"other","alto","contralto","soprano","bass","baritone",
"tenor"};
void Singer::Set()
{
worker::Set();
cout << "Enter number for singer's vocal range : \n";
int i;
for (i = 0;i < Vtype; i++)
{
cout << i << ": "<<pv[i] << " ";
if (i % 4 == 3)
cout << endl;
}
if (i % 4 != 0)
cout << endl;
while (cin >> voice && (voice < 0) || voice >= Vtype) )
cout << "Please enter a value >= 0 and < " << Vtype <<endl;
while (cin.get()!='\n')
continue;
}
void Singer::Show() const
{
cout << "Category: Singer \n";
Worker::Show();
cout << "Vocal range : " << pv[voice] << endl;
}