workermi.cpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. // workermi.cpp -- working class methods with MI
  2. #include "workermi.h"
  3. #include <iostream>
  4. using std::cout;
  5. using std::cin;
  6. using std::endl;
  7. // Worker methods
  8. Worker::~Worker() { }
  9. // protected methods
  10. void Worker::Data() const
  11. {
  12. cout << "Name: " << fullname << endl;
  13. cout << "Employee ID: " << id << endl;
  14. }
  15. void Worker::Get()
  16. {
  17. getline(cin, fullname);
  18. cout << "Enter worker's ID: ";
  19. cin >> id;
  20. while (cin.get() != '\n')
  21. continue;
  22. }
  23. // Waiter methods
  24. void Waiter::Set()
  25. {
  26. cout << "Enter waiter's name: ";
  27. Worker::Get();
  28. Get();
  29. }
  30. void Waiter::Show() const
  31. {
  32. cout << "Category: waiter\n";
  33. Worker::Data();
  34. Data();
  35. }
  36. // protected methods
  37. void Waiter::Data() const
  38. {
  39. cout << "Panache rating: " << panache << endl;
  40. }
  41. void Waiter::Get()
  42. {
  43. cout << "Enter waiter's panache rating: ";
  44. cin >> panache;
  45. while (cin.get() != '\n')
  46. continue;
  47. }
  48. // Singer methods
  49. char * Singer::pv[Singer::Vtypes] = {"other", "alto", "contralto",
  50. "soprano", "bass", "baritone", "tenor"};
  51. void Singer::Set()
  52. {
  53. cout << "Enter singer's name: ";
  54. Worker::Get();
  55. Get();
  56. }
  57. void Singer::Show() const
  58. {
  59. cout << "Category: singer\n";
  60. Worker::Data();
  61. Data();
  62. }
  63. // protected methods
  64. void Singer::Data() const
  65. {
  66. cout << "Vocal range: " << pv[voice] << endl;
  67. }
  68. void Singer::Get()
  69. {
  70. cout << "Enter number for singer's vocal range:\n";
  71. int i;
  72. for (i = 0; i < Vtypes; i++)
  73. {
  74. cout << i << ": " << pv[i] << " ";
  75. if ( i % 4 == 3)
  76. cout << endl;
  77. }
  78. if (i % 4 != 0)
  79. cout << '\n';
  80. while (cin >> voice && (voice < 0 || voice >= Vtypes) )
  81. cout << "Please enter a value >= 0 and < " << Vtypes << endl;
  82. while (cin.get() != '\n')
  83. continue;
  84. }
  85. // SingingWaiter methods
  86. void SingingWaiter::Data() const
  87. {
  88. Singer::Data();
  89. Waiter::Data();
  90. }
  91. void SingingWaiter::Get()
  92. {
  93. Waiter::Get();
  94. Singer::Get();
  95. }
  96. void SingingWaiter::Set()
  97. {
  98. cout << "Enter singing waiter's name: ";
  99. Worker::Get();
  100. Get();
  101. }
  102. void SingingWaiter::Show() const
  103. {
  104. cout << "Category: singing waiter\n";
  105. Worker::Data();
  106. Data();
  107. }