Television - #include #include using...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
#include <iostream> #include <string> using namespace std; class Television { /* class-level attributes */ static const int MIN_VOLUME = 0; static const int MAX_VOLUME = 10; static const int MIN_CHANNEL = 2; static const int MAX_CHANNEL = 99; private: // Data members of instance /** Whether the power is on */ bool powerOn; /** Whether the tv is muted */ bool muted; /** The current volume level */ int volume; /** The most recent previous channel number */ int prevChan; int channel; int temp; public: /** Creates a new Television instance. * * The power is initially off. Upon the first time the TV is turned on, * it will be set to channel 2, and a volume level of 5. */ Television() { powerOn = false; muted = false; volume = 5; channel = 2; prevChan = 2; } /** Toggles the power setting. * * If Television is off, turns it on. * If Television is on, turns it off. */ void togglePower() { powerOn = !powerOn; } /** Toggles the setting for mute. * * If power is off, there is no effect. * * Otherwise, if television was unmuted, it becomes muted.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
* If television was muted, it becomes unmuted and the volume is * restored to its previous setting. */ void toggleMute() { if (powerOn) { muted = !muted;} } /** Increments the volume of the Television by one increment. * * If power is currently off, there is no effect (-1 returned). * Otherwise, updates the volume setting appropriately.
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 05/03/2011 for the course CSCI 180 taught by Professor Goldwasser,m during the Fall '08 term at Saint Louis.

Page1 / 5

Television - #include #include using...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online