tv.cpp 1015 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // tv.cpp -- methods for the Tv class (Remote methods are inline)
  2. #include <iostream>
  3. #include "tv.h"
  4. bool Tv::volup()
  5. {
  6. if (volume < MaxVal)
  7. {
  8. volume++;
  9. return true;
  10. }
  11. else
  12. return false;
  13. }
  14. bool Tv::voldown()
  15. {
  16. if (volume > MinVal)
  17. {
  18. volume--;
  19. return true;
  20. }
  21. else
  22. return false;
  23. }
  24. void Tv::chanup()
  25. {
  26. if (channel < maxchannel)
  27. channel++;
  28. else
  29. channel = 1;
  30. }
  31. void Tv::chandown()
  32. {
  33. if (channel > 1)
  34. channel--;
  35. else
  36. channel = maxchannel;
  37. }
  38. void Tv::settings() const
  39. {
  40. using std::cout;
  41. using std::endl;
  42. cout << "TV is " << (state == Off? "Off" : "On") << endl;
  43. if (state == On)
  44. {
  45. cout << "Volume setting = " << volume << endl;
  46. cout << "Channel setting = " << channel << endl;
  47. cout << "Mode = "
  48. << (mode == Antenna? "antenna" : "cable") << endl;
  49. cout << "Input = "
  50. << (input == TV? "TV" : "DVD") << endl;
  51. }
  52. }