Question: QUESTION: ADD COMMENTS FOR THE CODE LISTED BELOW include #include #include #include #include using namespace std; //Class Piano is created class Piano { //Class Variables

QUESTION: ADD COMMENTS FOR THE CODE LISTED BELOW

include

#include

#include

#include

#include

using namespace std;

//Class Piano is created

class Piano {

//Class Variables are defined

private:

string notes;

//Class functions are defined

public:

Piano() {

notes = "";

}

//Grabs note form existing file

void LoadNotes(string filename) {

char note;

ifstream IN_file(filename);

if (!IN_file.is_open())

while (IN_file.get(note)) {

notes += note;

}

IN_file.close();

}

//Plays Notes: do re mi fa sol la si do re mi fa sol

void PlayNotes() {

for (const auto& note : notes) {

if (note == 'a') {

Beep(261, 100);

}

if (note == 's') {

Beep(293, 100);

}

if (note == 'd') {

Beep(329, 100);

}

if (note == 'f') {

Beep(349, 100);

}

if (note == 'g') {

Beep(392, 100);

}

if (note == 'h') {

Beep(440, 100);

}

if (note == 'j') {

Beep(493, 100);

}

if (note == 'k') {

Beep(523, 100);

}

if (note == 'l') {

Beep(587, 100);

}

if (note == ';') {

Beep(659, 100);

}

if (note == '\'') {

Beep(698, 100);

}

if (note == '\\') {

Beep(784, 100);

}

//Plays Notes: rebemol mibemol solbemol labemol sibemol rebemol mibemol solbemol

if (note == 'w') {

Beep(277, 100);

}

if (note == 'e') {

Beep(311, 100);

}

if (note == 't') {

Beep(370, 100);

}

if (note == 'y') {

Beep(415, 100);

}

if (note == 'u') {

Beep(466, 100);

}

if (note == 'o') {

Beep(554, 100);

}

if (note == 'p') {

Beep(622, 100);

}

if (note == ']') {

Beep(740, 100);

}

}

}

};

int main(int argc, char* argv[])

{

Piano mypiano;// piano object is created

mypiano.LoadNotes("C:\\Temp\\input.txt");// grabs notes from file

mypiano.PlayNotes();//runs notes that were taken from the file

return EXIT_SUCCESS;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!