#ifndef TELEVISION_H #define TELEVISION_H #include #include class Television { private: bool powerOn; bool muted; int volume; int prevChan; int minVolume; int maxVolume; int minChannel; int maxChannel; 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(); /** 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. If television was muted, it becomes unmuted and the volume is restored to its previous setting. */ toggleMute(); /** 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 appropraitely, and returns the new setting value to the caller. If television is currently muted, it will be unmuted as a result. If volume was at maximum level, it remains at maximum level. */ int volumeUp(); /** Decrements the volume of the Television by one increment. If power is currently off, there is no effect (-1 returned). Otherwise, updates the volume setting appropraitely, and returns the new setting value to the caller. If television is currently muted, it will be unmuted as a result. If volume was at minimum level, it remains at minimum level. */ int volumeDown(); /** Increments the channel. If power is off, there is no effect (-1 returned). If channel had been set to the maximum of the valid range of channels, the effect will be to 'wrap' around resulting in the channel being set to the minimum channel. Returns the resulting channel setting */ int channelUp(); /** Decrements the channel. If power is off, there is no effect (-1 returned). If channel had been set to the minimum of the valid range of channels, the effect will be to 'wrap' around resulting in the channel being set to the maximum channel. Returns the resulting channel setting */ int channelDown(); /** If the specified number is a valid channel, sets the channel to that value. Returns a boolean value which is true if the number was indeed legitimate, and false otherwise If power is off, there is no effect. */ bool setChannel(); /** Changes the channel to be that of the most recent other channel to have been viewed. Returns the resulting channel setting If power is off, there is no effect. */ int jumpPrevChannel() const; /** Returns a str object representing the current observable settings. */ std::string toString() const; }; /* * Overloading the output operator. */ std::ostream& operator<<(std::ostream& out, const Television& tv); #endif