worker0.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // worker0.cpp -- working class methods
  2. #include "worker0.h"
  3. #include <iostream>
  4. using std::cout;
  5. using std::cin;
  6. using std::endl;
  7. // Worker methods
  8. // must implement virtual destructor, even if pure
  9. Worker::~Worker() {}
  10. void Worker::Set()
  11. {
  12. cout << "Enter worker's name: ";
  13. getline(cin, fullname);
  14. cout << "Enter worker's ID: ";
  15. cin >> id;
  16. while (cin.get() != '\n')
  17. continue;
  18. }
  19. void Worker::Show() const
  20. {
  21. cout << "Name: " << fullname << "\n";
  22. cout << "Employee ID: " << id << "\n";
  23. }
  24. // Waiter methods
  25. void Waiter::Set()
  26. {
  27. Worker::Set();
  28. cout << "Enter waiter's panache rating: ";
  29. cin >> panache;
  30. while (cin.get() != '\n')
  31. continue;
  32. }
  33. void Waiter::Show() const
  34. {
  35. cout << "Category: waiter\n";
  36. Worker::Show();
  37. cout << "Panache rating: " << panache << "\n";
  38. }
  39. // Singer methods
  40. char * Singer::pv[] = {"other", "alto", "contralto",
  41. "soprano", "bass", "baritone", "tenor"};
  42. void Singer::Set()
  43. {
  44. Worker::Set();
  45. cout << "Enter number for singer's vocal range:\n";
  46. int i;
  47. for (i = 0; i < Vtypes; i++)
  48. {
  49. cout << i << ": " << pv[i] << " ";
  50. if ( i % 4 == 3)
  51. cout << endl;
  52. }
  53. if (i % 4 != 0)
  54. cout << endl;
  55. while (cin >> voice && (voice < 0 || voice >= Vtypes) )
  56. cout << "Please enter a value >= 0 and < " << Vtypes << endl;
  57. while (cin.get() != '\n')
  58. continue;
  59. }
  60. void Singer::Show() const
  61. {
  62. cout << "Category: singer\n";
  63. Worker::Show();
  64. cout << "Vocal range: " << pv[voice] << endl;
  65. }