Last active
August 29, 2015 13:56
Revisions
-
dishbreak revised this gist
Mar 2, 2014 . 1 changed file with 8 additions and 0 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ Television * tv = new Television(); //conditional is true if call to pressPowerButton() is false. if ( !( tv->pressPowerButton() ) ) { //alert! We have an issue } ... -
dishbreak revised this gist
Mar 2, 2014 . 4 changed files with 92 additions and 92 deletions.There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,13 +1,13 @@ void Television::pressPowerButton() { tvIsOn = !tvIsOn; if (tvIsOn == true) { turnOn(); } else { turnOff(); } } This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,14 +1,14 @@ class Television { public: Television(); ~Television(); void pressPowerButton(); private: bool tvIsOn; //state variable void turnOn(); void turnOff(); }; This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,65 +1,65 @@ Television::Television() { //on creation, the television is off. tvIsOn = false; } Television::~Television() { } bool Television::pressPowerButton() { //if the current state is on, try to turn off if (tvIsOn == true) { tvIsOn = turnOff(); } //otherwise, the current state is off, so try to turn on else { tvIsOn = turnOn(); } //report the current state back to the user return tvIsOn; } bool Television::turnOn() { //set a variable for success bool success = false; //do stuff to turn on, set success variable accordingly. //if we succeeded, return the new state of "on". if (success) { return true; } //otherwise, keep the state as "off". else { return false; } } bool Television::turnOff() { //set a variable for success bool success = false; //do stuff to turn off, set success variable //if we succeeded, return the new state of "off". if (success) { return false; } //otherwise, keep the state as "on". else { return true; } } This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,14 +1,14 @@ class Television { public: Television(); ~Television(); bool pressPowerButton(); private: bool tvIsOn; //state variable bool turnOn(); bool turnOff(); }; -
dishbreak created this gist
Mar 2, 2014 .There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ void Television::pressPowerButton() { tvIsOn = !tvIsOn; if (tvIsOn == true) { turnOn(); } else { turnOff(); } } This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ class Television { public: Television(); ~Television(); void pressPowerButton(); private: bool tvIsOn; //state variable void turnOn(); void turnOff(); }; This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,65 @@ Television::Television() { //on creation, the television is off. tvIsOn = false; } Television::~Television() { } bool Television::pressPowerButton() { //if the current state is on, try to turn off if (tvIsOn == true) { tvIsOn = turnOff(); } //otherwise, the current state is off, so try to turn on else { tvIsOn = turnOn(); } //report the current state back to the user return tvIsOn; } bool Television::turnOn() { //set a variable for success bool success = false; //do stuff to turn on, set success variable accordingly. //if we succeeded, return the new state of "on". if (success) { return true; } //otherwise, keep the state as "off". else { return false; } } bool Television::turnOff() { //set a variable for success bool success = false; //do stuff to turn off, set success variable //if we succeeded, return the new state of "off". if (success) { return false; } //otherwise, keep the state as "on". else { return true; } } This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ class Television { public: Television(); ~Television(); bool pressPowerButton(); private: bool tvIsOn; //state variable bool turnOn(); bool turnOff(); };