There were five distinct bugs. Diagnosing each was worth 4 points.
Error message:
Television.cpp:43: error: ISO C++ forbids declaration of 'togglePower' with no type
Diagnosis: The problem is that the signature for the togglePower() method does not explicitly specify any return type. Though this method does not return anything, it is still necessary to make this expectation explicit by declaring a void return type, making line 43 read:
void togglePower() { powerOn = !powerOn; }
Error message:
Television.cpp:150: error: 'number' has not been declared
Diagnosis: The problem here is that the parameter, number, specified in the signature of setChannel does not have an explicitly declared type. We can fix this by changing line 150 to read
bool setChannel(int number) {
Error message:
Television.cpp: In constructor 'Television::Television()': Television.cpp:36: error: 'channel' was not declared in this scope
Diagnosis: Our constructor initialize list is trying to assign a value to channel, which presumably is meant to be a data member for this instance. However no such data member was declared. We will fix this by inserting the following in the private section of the class definition.
starting at line 25 of the file./** The current channel number */ int channel;
Error message:
Television.cpp: In member function 'int Television::channelDown()':
Television.cpp:135: error: expected `(' before 'powerOn'
Television.cpp:141: error: expected `}' before 'else'
(note: line numbers here reflect previous changes)
Diagnosis: The problem here is with the original if statement. The boolean expressions defining the condition must be enclosed within parentheses in C++. Therefore, it should be written as
if (powerOn) {
at what is now line 135 (originallly line 132).
Error message:
Television.cpp: In member function 'int Television::jumpPrevChannel() const': Television.cpp:172: error: assignment of data-member 'Television::channel' in read-only structure Television.cpp:173: error: assignment of data-member 'Television::prevChan' in read-only structure
Diagnosis: We originally declared jumpPrevChannel() as a const method. As such, its body should not alter the state of the object. Yet our body clearly does alter the state, at revised lines 172 and 173 of Television.cpp (the members channel and prevChannel).
We must either change the body so as not to alter the object, or change the declaration of the function to remove the const label. In this case, the correct remedy is to remove the const label from the signature at what is now line 168 (originally line 165).