Princeton Legree

Princeton Legree

Favorite Quotations

"Knowledge makes a man unfit to be a slave."
-Frederick Douglas

"It is no measure of mental health to be well adjusted to a profoundly sick society."
-Jiddu Krishnamurti

"Adversity makes men. Prosperity makes monsters."
-Victor Hugo

"If you will not fight for the right when you can easily win without bloodshed, if you will not fight when your victory will be sure and not so costly, you may come to the moment when you will have to fight with all the odds against you and only a precarious change for survival. There may be a worse case. You may have to fight when there is no chance of victory, because it is better to perish than to live as slaves."
-Winston Churchill

"Truth is stranger than fiction, but it is because Fiction is obliged to stick to possibilities; Truth isn't."
-Mark Twain

"I have sworn upon the altar of God, eternal hostility against every form of tyranny over the mind of man."
-Thomas Jefferson

"People sleep peaceably in their beds at night only because rough men stand ready to do violence on their behalf."
-George Orwell

"What gets us into trouble is not what we don't know. It's what we know for sure that just ain't so."
-Mark Twain

"The Internet is the first thing that humanity has built that humanity doesn't understand, the largest experiment in anarchy that we have ever had.”
-Eric Schmidt

"If you want to tell people the truth, make them laugh. Otherwise, they'll kill you."
-Oscar Wilde

"We are all brothers under the skin and I, for one, would be willing to skin humanity to prove it."
-Ayn Rand

"Security is mostly a superstition. It does not exist in nature, nor do the children of men as a whole experience it. Avoiding danger is no safer in the long run than outright exposure. Life is either a daring adventure, or nothing."
-Helen Keller

"I never learned how to tune a harp, or play upon a lute; but I know how to raise a small and obscure city to glory and greatness...whereto all kindreds of the earth will pilgrim."
-The Greek Admiral Themistocles

“The future belongs to those who believe in the beauty of their dreams.”
-Eleanor Roosevelt

Princeton's SWITCH DEMO - Scribbler Game

//Name: Princeton Legree //USCID: 803077613 //HW: 6 - What is CS? #include #include "Myro.h" #include #include #include #include #include #include #include #include #include #include #include #include "TrialEval.h" using namespace std; class TrialEval{ public: TrialEval(); ~TrialEval(); void set_name(string x); string get_name(); //void get_name(string &); // test---------- int set_songGuess(int i, int x); int get_songGuess(int i); int set_numCorrect(int x); int get_numCorrect(); bool set_YDC(bool x); bool get_YDC(); private: int songGuess[27]; int numCorrect; bool YDCorrect; bool random; string name; }; TrialEval::TrialEval(){ for(int i = 0; i < 27; i++) songGuess[i] = 0; numCorrect = 0; YDCorrect = false; name = "unknown"; } void TrialEval::set_name(string x){ name = x; } string TrialEval::get_name(){ return name; } /*void TrialEval::get_name(string &x){ x = name; }*/ int TrialEval::set_songGuess(int i, int x){ songGuess[i] = x; } int TrialEval::get_songGuess(int i){ return songGuess[i]; } int TrialEval::set_numCorrect(int x){ numCorrect = x; } int TrialEval::get_numCorrect(){ return numCorrect; } bool TrialEval::set_YDC(bool x){ YDCorrect = x; } bool TrialEval::get_YDC(){ return YDCorrect; } TrialEval::~TrialEval(){ } void GUI(int &); void GUIYD(); void GUIRepeat(int & repeat); void sing(TrialEval [], int); void drawStar(); double normalize(int, double); void printstats(TrialEval [], int); void graphstats(); int main() { int trial = 0; int repeat = 1; int choice = 0; int choicex = 0; string name; TrialEval Eval[25]; while (repeat != 0 && trial < 25){ choice = 0; GUI(choice); // SWITCH APPLICATION switch(choice){ case 1: GUIYD(); connect("/dev/ttyS0"); sing(Eval, trial); disconnect(); cout << "Please enter your first name only: "; cin >> name; cout << endl; Eval[trial].set_name(name); if (repeat == 1){ trial = trial + 1; } choicex = 1; GUIRepeat(repeat); break; case 2: graphstats(); GUIRepeat(repeat); trial = trial - 1; break; } } if(choicex == 1) printstats(Eval, trial); //Test for song_guess input. /*for (int v = 0; v < trial+1; v++){ cout << "song guess trial" << v << ":"; for (int f = 0; f < 27; f++){ cout << Eval[v].get_songGuess(f); }cout << endl;}*/ cout << "GameOver: Either user terminated program willfully or the maximum number of restarts has been reached. Restart program from terminal to play again. Thank you for playing!" << endl; return 0; } void GUI(int &choice) { //Basic Design GraphWin interface ("Princeton's Scribbler Games", 500, 400); interface.setBackground("Lavender"); for (int n = 0; n < 501; n = n + 5){ Line L1 = Line(Point(n,0), Point(250, 300)); L1.draw(interface); } Rectangle titleHead = Rectangle(Point(0,0), Point(500,151)); titleHead.setFill("Lavender"); titleHead.setOutline("Maroon"); Rectangle titleHead2 = Rectangle(Point(0,0), Point(500,150)); titleHead2.setFill("Lavender"); titleHead2.setOutline("Lavender"); titleHead.draw(interface); titleHead2.draw(interface); Rectangle titleHead3 = Rectangle(Point(0,240), Point(500,400)); titleHead3.setFill("Lavender"); titleHead3.setOutline("Maroon"); Rectangle titleHead4 = Rectangle(Point(0,241), Point(500,400)); titleHead4.setFill("Lavender"); titleHead4.setOutline("Lavender"); titleHead3.draw(interface); titleHead4.draw(interface); //Title Text title = Text(Point(20, 75), "Welcome to Princeton's Scribbler Games!"); title.setTextColor("Maroon"); title.setStyle("Bold"); title.setSize(27); title.draw(interface); //Button to select Yankee Doodle game Rectangle YDToken = Rectangle(Point(25,275), Point(200,350)); YDToken.setFill("Maroon"); YDToken.setOutline("gold"); YDToken.draw(interface); Text YDTitle = Text(Point(45, 302), "Play Yankee Doodle!"); YDTitle.setTextColor("Gold"); YDTitle.setStyle("Bold"); YDTitle.setSize(18); YDTitle.draw(interface); //Button to view game statistics Rectangle DrawToken = Rectangle(Point(300,275), Point(475,350)); DrawToken.setFill("Maroon"); DrawToken.setOutline("gold"); DrawToken.draw(interface); Text DTitle = Text(Point(310, 302), "View Game Statistics."); DTitle.setTextColor("Gold"); DTitle.setStyle("Bold"); DTitle.setSize(17); DTitle.draw(interface); //to Click int q = 0; int w = 0; int click; Point mousePosition = Point(q,w); while(!interface.isClosed()){ mousePosition = interface.getMouse(); if (mousePosition.getX() > 25 && mousePosition.getX() < 201 && mousePosition.getY() > 275 && mousePosition.getY() < 350){ //cout << "Yankee Doodle!" << endl; choice = 1; wait(0.05); break; } else if (mousePosition.getX() >= 300 && mousePosition.getX() < 476 && mousePosition.getY() > 275 && mousePosition.getY() < 350){ //cout << "Stats!" << endl; choice = 2; wait(0.05); break; } } interface.close(); } void GUIYD() { //Basic Design GraphWin YDGIF ("Princeton's Scribbler Games - Yankee Doodle", 500, 400); YDGIF.setBackground("Lavender"); for (int n = 0; n < 501; n = n + 5){ Line L1 = Line(Point(n,0), Point(250, 300)); L1.draw(YDGIF); } //Title Rectangle titleHead = Rectangle(Point(0,0), Point(500,51)); titleHead.setFill("Lavender"); titleHead.setOutline("Maroon"); Rectangle titleHead2 = Rectangle(Point(0,0), Point(500,50)); titleHead2.setFill("Lavender"); titleHead2.setOutline("Lavender"); titleHead.draw(YDGIF); titleHead2.draw(YDGIF); Text title = Text(Point(20, 15), "Princeton's Scribbler Games - Yankee Doodle!"); title.setTextColor("Maroon"); title.setStyle("Bold"); title.setSize(23); title.draw(YDGIF); //Yankee Doodle game description Rectangle YDToken = Rectangle(Point(25,75), Point(475,375)); YDToken.setFill("Maroon"); YDToken.setOutline("gold"); YDToken.draw(YDGIF); Text YDTitle = Text(Point(167, 90), "Play Yankee Doodle!"); YDTitle.setTextColor("Gold"); YDTitle.setStyle("Bold"); YDTitle.setSize(19); YDTitle.draw(YDGIF); Text YDirect1 = Text(Point(40, 115), "Directions: Shine a flashlight on one of the five sensors on"); YDirect1.setTextColor("Gold"); YDirect1.setStyle("Bold"); YDirect1.setSize(17); YDirect1.draw(YDGIF); Text YDirect2 = Text(Point(40, 130), "the robot to make it play a tone. If you choose the right"); YDirect2.setTextColor("Gold"); YDirect2.setStyle("Bold"); YDirect2.setSize(17); YDirect2.draw(YDGIF); Text YDirect3 = Text(Point(40, 145), "sequence of tones for Yankee Doodle the song, the robot"); YDirect3.setTextColor("Gold"); YDirect3.setStyle("Bold"); YDirect3.setSize(17); YDirect3.draw(YDGIF); Text YDirect4 = Text(Point(40, 160), "will give you a special surprise! You will have 2 seconds"); YDirect4.setTextColor("Gold"); YDirect4.setStyle("Bold"); YDirect4.setSize(17); YDirect4.draw(YDGIF); Text YDirect5 = Text(Point(40, 175), "to properly stimulate one of the robot's five senses before"); YDirect5.setTextColor("Gold"); YDirect5.setStyle("Bold"); YDirect5.setSize(17); YDirect5.draw(YDGIF); Text YDirect6 = Text(Point(40, 190), "the robot proceeds to collect the next beep. Yankee Doodle"); YDirect6.setTextColor("Gold"); YDirect6.setStyle("Bold"); YDirect6.setSize(17); YDirect6.draw(YDGIF); Text YDirect7 = Text(Point(40, 205), "reqires 27 beeps. Accordingly, the robot will only record 27"); YDirect7.setTextColor("Gold"); YDirect7.setStyle("Bold"); YDirect7.setSize(17); YDirect7.draw(YDGIF); Text YDirect8 = Text(Point(40, 220), "beeps, thus this game lasts approximately 54 seconds. Begin"); YDirect8.setTextColor("Gold"); YDirect8.setStyle("Bold"); YDirect8.setSize(17); YDirect8.draw(YDGIF); Text YDirect9 = Text(Point(40, 235), "when you hear the robot beep to signal that it is connected"); YDirect9.setTextColor("Gold"); YDirect9.setStyle("Bold"); YDirect9.setSize(17); YDirect9.draw(YDGIF); Text YDirect10 = Text(Point(40, 250), "and afterwards, please enter your name in the terminal."); YDirect10.setTextColor("Gold"); YDirect10.setStyle("Bold"); YDirect10.setSize(17); YDirect10.draw(YDGIF); Text YDirect11 = Text(Point(60, 280), "Left I = B note, Left LC = C note, Center LC = D note"); YDirect11.setTextColor("Gold"); YDirect11.setStyle("Bold"); YDirect11.setSize(17); YDirect11.draw(YDGIF); Text YDirect12 = Text(Point(120, 295), "Right LC = E note, Right I = F note"); YDirect12.setTextColor("Gold"); YDirect12.setStyle("Bold"); YDirect12.setSize(17); YDirect12.draw(YDGIF); Text YDirect13 = Text(Point(80, 315), "'I' means infrared censor, 'LC' means light censor"); YDirect13.setTextColor("Gold"); YDirect13.setStyle("Bold"); YDirect13.setSize(17); YDirect13.draw(YDGIF); Text YDirect14 = Text(Point(50, 333), "[Click anywhere on this screen to exit and play the game."); YDirect14.setTextColor("Gold"); YDirect14.setStyle("Bold"); YDirect14.setSize(17); YDirect14.draw(YDGIF); Text YDirect15 = Text(Point(80, 350), "Do NOT click on the X button in the top left.]"); YDirect15.setTextColor("Gold"); YDirect15.setStyle("Bold"); YDirect15.setSize(17); YDirect15.draw(YDGIF); YDGIF.getMouse(); } void GUIRepeat(int & repeat) { //Basic Design GraphWin GUIR ("Princeton's Scribbler Games", 500, 400); GUIR.setBackground("Lavender"); for (int n = 0; n < 501; n = n + 5){ Line L1 = Line(Point(n,0), Point(250, 300)); L1.draw(GUIR); } Rectangle titleHead = Rectangle(Point(0,0), Point(500,151)); titleHead.setFill("Lavender"); titleHead.setOutline("Maroon"); Rectangle titleHead2 = Rectangle(Point(0,0), Point(500,150)); titleHead2.setFill("Lavender"); titleHead2.setOutline("Lavender"); titleHead.draw(GUIR); titleHead2.draw(GUIR); Rectangle titleHead3 = Rectangle(Point(0,240), Point(500,400)); titleHead3.setFill("Lavender"); titleHead3.setOutline("Maroon"); Rectangle titleHead4 = Rectangle(Point(0,241), Point(500,400)); titleHead4.setFill("Lavender"); titleHead4.setOutline("Lavender"); titleHead3.draw(GUIR); titleHead4.draw(GUIR); //Title Text title = Text(Point(50, 20), "Princeton's Scribbler Games!"); title.setTextColor("Maroon"); title.setStyle("Bold"); title.setSize(27); title.draw(GUIR); //Directios Text RDirect = Text(Point(25, 75), "Would you like to start again from the main menu?"); RDirect.setTextColor("Maroon"); RDirect.setStyle("Bold"); RDirect.setSize(20); RDirect.draw(GUIR); //Button for Yes Rectangle YDToken = Rectangle(Point(25,275), Point(200,350)); YDToken.setFill("Maroon"); YDToken.setOutline("gold"); YDToken.draw(GUIR); Text YDTitle = Text(Point(90, 302), "Yes."); YDTitle.setTextColor("Gold"); YDTitle.setStyle("Bold"); YDTitle.setSize(25); YDTitle.draw(GUIR); //Button for No Rectangle DrawToken = Rectangle(Point(300,275), Point(475,350)); DrawToken.setFill("Maroon"); DrawToken.setOutline("gold"); DrawToken.draw(GUIR); Text DTitle = Text(Point(380, 302), "No."); DTitle.setTextColor("Gold"); DTitle.setStyle("Bold"); DTitle.setSize(25); DTitle.draw(GUIR); //to Click int q = 0; int w = 0; int click; Point mousePosition = Point(q,w); while(!GUIR.isClosed()){ mousePosition = GUIR.getMouse(); if (mousePosition.getX() > 25 && mousePosition.getX() < 201 && mousePosition.getY() > 275 && mousePosition.getY() < 350){ repeat = 1; wait(0.05); break; } else if (mousePosition.getX() >= 300 && mousePosition.getX() < 476 && mousePosition.getY() > 275 && mousePosition.getY() < 350){ repeat = 0; wait(0.05); break; } } GUIR.close(); } void sing(TrialEval Eval[], int trial) { int YDSong[27] = {2,2,3,4,2,4,3,2,2,3,4,2,1,2,2,3,4,5,4,3,2,1,1,2,3,2,2}; int guess[27] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; int noteChoice = 0; int FL = 1; int L = 0; int C = 0; int R = 0; int FR = 1; int correctTones = 0; double Ambient; bool correct = false; for (int i = 0; i < 27; i++){ wait(2.0); Ambient = (robot.getLight("left") + robot.getLight("center")+ robot.getLight("right"))/3.0; noteChoice = 0; int FL =robot.getIR("Left"); //cout << "FL" << i <<": " << FL << endl; //Test for left IR's input int L = robot.getLight("left"); //cout << "L" << i <<": " << L << endl; //Test for left photoreceptor's input int C = robot.getLight("center"); //cout << "C" << i <<": " << C << endl; //Test for center photoreceptor's input int R = robot.getLight("right"); //cout << "R" << i <<": " << R << endl; //Test for right photoreceptor's input int FR = robot.getIR("Right"); //cout << "FR" << i <<": " << FR << endl; //Test for right IR's input if (FL == 1) noteChoice = 1; else if (/*L > R && L > C &&*/ L < 10000) noteChoice = 4; else if (/*R > L && R > C &&*/ R < 10000) noteChoice = 2; else if (/*C > L && C > R &&*/ C < 10000) noteChoice = 3; else if (FR == 1) noteChoice = 5; else noteChoice = 0; //cout << noteChoice << endl; //Test to analyze results of if..else structure above //SWITCH APPLICATION switch (noteChoice){ case 1: robot.beep(2, 493.883); //play B guess[i] = 1; //record user's answer Eval[trial].set_songGuess(i, guess[i]); break; case 2: robot.beep(2, 523.25); //play C guess[i] = 2; //record user's answer Eval[trial].set_songGuess(i, guess[i]); break; case 3: robot.beep(2, 587.32); //play D guess[i] = 3; //record user's answer Eval[trial].set_songGuess(i, guess[i]); break; case 4: robot.beep(2, 659.256); //play E guess[i] = 4; //record user's answer Eval[trial].set_songGuess(i, guess[i]); break; case 5: robot.beep(2, 698.456); //play F guess[i] = 5; //record user's answer Eval[trial].set_songGuess(i, guess[i]); break; default: break; } } //check play's answer against answer key for (int i = 0; i < 27; i++){ if (YDSong[i] == guess[i]) correctTones++; } //store correctTones for the graph Eval[trial].set_numCorrect(correctTones); //check for 18 out of 27 correctness (It was 27/27 but I reduced it to make it easier for the kids) if (correctTones >= 18){ correct = true; } else{ correct = false; } if (correct == true){ drawStar(); Eval[trial].set_YDC(true); //record correctness } } void drawStar() { robot.forward(1,.5); //1 robot.turnLeft(1,.393); //2 robot.backward(1,.5); //3 robot.turnRight(1,.8); //4 robot.forward(1,.5); //5 robot.turnLeft(1,.393); //6 robot.backward(1,.5); //7 robot.turnRight(1,.8); //8 robot.forward(1,.5); //9 robot.turnLeft(1,.393); //10 robot.backward(1,.5); //11 robot.turnRight(1,.8); //12 robot.forward(1,.5); //13 robot.turnLeft(1,.393); //14 robot.backward(1,.5); //15 robot.turnRight(1,.8); //16 robot.forward(1,.5); //17 robot.turnLeft(1,.393); //18 robot.backward(1,.5); //19 robot.turnRight(1,.8); //20 robot.forward(1,.5); //21 robot.turnLeft(1,.393); //22 robot.backward(1,.5); //23 robot.turnRight(1,.8); //24 robot.forward(1,.5); //25 robot.turnLeft(1,.393); //26 robot.backward(1,.5); //27 robot.turnRight(1,.8); //28 robot.forward(1,.5); //29 robot.turnLeft(1,.393); //30 robot.backward(1,.5); //31 robot.turnRight(1,.8); //32 } double normalize(int v, double A) { if (v > A){ v = A; } return 1.0 - v/A; } void printstats(TrialEval Eval[], int trial) { fstream outFile; outFile.open("Evaluation.txt", fstream::in | fstream::out | fstream::ate); if (trial <= 24){ for (int i = 0; i < trial+1; i++){ string printName; string product; ostringstream convert1; ostringstream convert2; int guessArray[27]; int number = 0; string tones; printName = Eval[i].get_name(); outFile << "Name:" << printName << '\n'; //cout << "Name:" << printName << endl; //test for correct read out. for (int p = 0; p < 27; p++) guessArray[p] = Eval[i].get_songGuess(p); for (int d = 0; d < 3; d++){ number = 0; for (int k = 0 ; k < 9 && k+(d*9) < 27; k++){ int g = k+(d*9); number = 10*number + guessArray[g]; //cout << "subtest" << d*k << ":" << product << endl; //test for correct int conversion } convert1 << number; product = convert1.str(); convert1.clear(); //cout << "test" << d+1 << ":" << product << endl; //test for correct string conversion } outFile << "Song guess:" << product << '\n'; //cout << "print_Song_guess:" << product << endl; //test for correct read out. convert2 << Eval[i].get_numCorrect(); tones = convert2.str(); outFile << "Correct tones:" << tones << '\n'; //cout << "Correct tones:" << tones << endl; //test for correct read out. if (Eval[i].get_YDC() == true){ outFile << "YD won:true" << '\n'; //cout << "YD Won:true" << endl; //test for correct read out. } else if (Eval[i].get_YDC() == false){ outFile << "YD won:false" << '\n'; //cout << "YD Won:false" << endl; //test for correct read out. } }} outFile.close(); } void graphstats() { //Read in Evaluation.txt string line; string tempString; string input; int value; int position1; int position2; char YDGuess[28]; int rounds = 0; TrialEval Graph[100]; ifstream inFile; inFile.open("Evaluation.txt"); if (inFile.fail()){ cout << "read in test result: fail/bad/eof" << endl; //test for failure } else{ //cout << "test: progress" << endl; //test for read in success while(inFile.good()){ //cout << "test: Hooyah" << endl; //2nd read in test while (getline(inFile, line) && rounds < 100){ //cout << "line: "<< line << endl; //test for correct line read in istringstream iss(line); string data; if(getline(iss, data, ':')){ //cout << data << endl; //test for correct header read in if(data == "Name"){ getline(iss, input, '\n'); //cout << "input:" << input << endl; //test for correct input read in Graph[rounds].set_name(input); } if(data == "Song guess"){ getline(iss, input, '\n'); //cout << "input:" << input << endl; //test for correct input read in strcpy(YDGuess, input.c_str()); for (int i = 0; i < 27; i++){ value = YDGuess[i]-'0'; Graph[rounds].set_songGuess(i, value); } } if(data == "Correct tones"){ getline(iss, input, '\n'); //cout << "input:" << input << endl; //test for correct input read in value = atoi(input.c_str()); Graph[rounds].set_numCorrect(value); } if(data == "YD won"){ getline(iss, input, '\n'); //cout << "input:" << input << endl; //test for correct input read in if (input == "true") Graph[rounds].set_YDC(true); else if (input == "false") Graph[rounds].set_YDC(false); rounds++; } } } } } inFile.close(); //cout << rounds << endl; //Test to see if rounds is incrementing correctly //Graphwin Depiction - Yankee Doodle Graph GraphWin YDGraph ("Evaluation: Performance - Yankee Doodle", 500, 400); YDGraph.setBackground("Lavender"); //x axis and y axis Line X1 = Line(Point(50,275), Point(475, 275)); X1.draw(YDGraph); Line Y1 = Line(Point(50,40), Point(50, 275)); Y1.draw(YDGraph); //y axis: scale for (int i = 0; i < 28; i++){ string number; ostringstream convert; convert << i; number = convert.str(); int y = 270-(i*9); Text title = Text(Point(30, y), number); title.setTextColor("Maroon"); title.setStyle("Bold"); title.setSize(10); title.draw(YDGraph); } //x axis: trial number for (int i = 0; i <= rounds && i < 100; i++){ string number; ostringstream convert; convert << i; number = convert.str(); int x = 65 + i*(400/rounds); Text xaxis = Text(Point(x, 280), number); xaxis.setTextColor("Maroon"); xaxis.setStyle("Bold"); xaxis.setSize(10); xaxis.draw(YDGraph); } //x axis title Text xtitle = Text(Point(25, 295), "X-AXIS = Yankee Doodle game trial number; Y-AXIS = number of correct music tones"); xtitle.setTextColor("Maroon"); xtitle.setStyle("Bold"); xtitle.setSize(13); xtitle.draw(YDGraph); Text xtitle_2 = Text(Point(25, 310), "Trial '0' denotes the stats for a perfect score."); xtitle_2.setTextColor("Maroon"); xtitle_2.setStyle("Bold"); xtitle_2.setSize(13); xtitle_2.draw(YDGraph); //100 max display Text xtitle_end = Text(Point(25, 335), "Chart only displays 1st 100 scores stored on file. To see more, open Evaluation.txt and change"); xtitle_end.setTextColor("Maroon"); xtitle_end.setStyle("Bold"); xtitle_end.setSize(13); xtitle_end.draw(YDGraph); Text xtitle_end2 = Text(Point(25, 350), "the order of th trials. However, please do not change the position of top trial, PerfectScore."); xtitle_end2.setTextColor("Maroon"); xtitle_end2.setStyle("Bold"); xtitle_end2.setSize(13); xtitle_end2.draw(YDGraph); Text xtitle_end3 = Text(Point(25, 365), "Also, each score must maintain its format (Name, Song guess, Correct tones, and YD won)."); xtitle_end3.setTextColor("Maroon"); xtitle_end3.setStyle("Bold"); xtitle_end3.setSize(13); xtitle_end3.draw(YDGraph); //ploting values for (int i = 0; i < rounds+1 && i < 100; i++){ if ((i+1) != (rounds+1)){ int x1 = 65+ i*(400/rounds); int y1 = 275-((Graph[i].get_numCorrect())*9); int x2 = 65+ (i+1)*(400/rounds); int y2 = 275-((Graph[i+1].get_numCorrect())*9); Line L1 = Line(Point(x1, y1), Point(x2,y2)); L1.draw(YDGraph); } } //ploting x axis trial number next to values for (int i = 0; i < rounds+1 && i < 100; i++){ string number2; ostringstream convert2; convert2 << i; number2 = convert2.str(); int x = 65+ i*(400/rounds); int y = 270-((Graph[i].get_numCorrect())*9); Text xaxis = Text(Point(x, y), number2); xaxis.setTextColor("Maroon"); xaxis.setStyle("Bold"); xaxis.setSize(10); xaxis.draw(YDGraph); } //Closing Text Ctitle = Text(Point(25, 380), "[Please click anywhere on this window to exit. Please do NOT click on the top left X button.]"); Ctitle.setTextColor("Maroon"); Ctitle.setStyle("Bold"); Ctitle.setSize(13); Ctitle.draw(YDGraph); YDGraph.getMouse(); YDGraph.close(); //NEWGRAPH: Record the number of times a note is missed int Bwrong = 0; int Bposs = 0; int Cwrong = 0; int Cposs = 0; int Dwrong = 0; int Dposs = 0; int Ewrong = 0; int Eposs = 0; int Fwrong = 0; int Fposs = 0; /*for(int e = 0; e < 27; e++){ cout << "tone" << e << ":" << Graph[0].get_songGuess(e)<< endl; //test answer key }*/ for(int s = 1; s < rounds; s++){ for(int a = 0; a < 27; a++){ if (Graph[0].get_songGuess(a) == 1){ if(Graph[s].get_songGuess(a) != Graph[0].get_songGuess(a)) Bwrong++; Bposs++; } if (Graph[0].get_songGuess(a) == 2){ if(Graph[s].get_songGuess(a) != Graph[0].get_songGuess(a)) Cwrong++; Cposs++; } if (Graph[0].get_songGuess(a) == 3){ if(Graph[s].get_songGuess(a) != Graph[0].get_songGuess(a)) Dwrong++; Dposs++; } if (Graph[0].get_songGuess(a) == 4){ if(Graph[s].get_songGuess(a) != Graph[0].get_songGuess(a)) Ewrong++; Eposs++; } if (Graph[0].get_songGuess(a) == 5){ if(Graph[s].get_songGuess(a) != Graph[0].get_songGuess(a)) Fwrong++; Fposs++; } } } double Bwrongx = Bwrong; Bwrongx /= Bposs; double Cwrongx = Cwrong; Cwrongx /= Cposs; double Dwrongx = Dwrong; Dwrongx /= Dposs; double Ewrongx = Ewrong; Ewrongx /= Eposs; double Fwrongx = Fwrong; Fwrongx /= Fposs; //Test to see if the correct number of incorrect notes is being counted and calculated /*cout << Bwrong << endl; cout << Bposs << endl; cout << Bwrongx << endl; cout << Cwrong << endl; cout << Cposs << endl; cout << Cwrongx << endl; cout << Dwrong << endl; cout << Dposs << endl; cout << Dwrongx << endl; cout << Ewrong << endl; cout << Eposs << endl; cout << Ewrongx << endl; cout << Fwrong << endl; cout << Fposs << endl; cout << Fwrongx << endl;*/ //Graphwin Depiction - Missed Notes GraphWin MNGraph ("Evaluation: Missed Notes - Yankee Doodle", 500, 400); MNGraph.setBackground("Lavender"); //x axis and y axis Line X12 = Line(Point(50,285), Point(475, 285)); X12.draw(MNGraph); Line Y12 = Line(Point(50,10), Point(50, 285)); Y12.draw(MNGraph); //y axis: scale for (int i = 0; i <= 100; i = i+10){ string number; ostringstream convert; convert << i; number = convert.str(); double y = 280-(i*2.75); Text yaxis2 = Text(Point(25, y), number); yaxis2.setTextColor("Maroon"); yaxis2.setStyle("Bold"); yaxis2.setSize(20); yaxis2.draw(MNGraph); } //x axis: Note title for (int i = 1; i < 6; i++){ string notewrong; //SWITCH APPLICATION switch(i){ case 1: notewrong = "Note: B wrong"; break; case 2: notewrong = "Note: C wrong"; break; case 3: notewrong = "Note: D wrong"; break; case 4: notewrong = "Note: E wrong"; break; case 5: notewrong = "Note: F wrong"; break; } int x = 65 + (i-1)*(400/5); Text xaxis2 = Text(Point(x, 290), notewrong); xaxis2.setTextColor("Maroon"); xaxis2.setStyle("Bold"); xaxis2.setSize(10); xaxis2.draw(MNGraph); } //x axis title Text xtitle2 = Text(Point(25, 320), "This graph shows how often a note has been missed when users play the game."); xtitle2.setTextColor("Maroon"); xtitle2.setStyle("Bold"); xtitle2.setSize(13); xtitle2.draw(MNGraph); //y axis title Text ytitle2 = Text(Point(25, 345), "NOTE: The numbers along the y-axis are percent values."); ytitle2.setTextColor("Maroon"); ytitle2.setStyle("Bold"); ytitle2.setSize(13); ytitle2.draw(MNGraph); //ploting bars for (int i = 1; i < 6; i++){ int x1 = 65+ (i-1)*(400/5); int y1; int x2 = 115 + (i-1)*(400/5); //SWITCH APPLICATION switch(i){ case 1: y1= 285-(Bwrongx*275); break; case 2: y1 = 285-(Cwrongx*275); break; case 3: y1 = 285-(Dwrongx*275); break; case 4: y1 = 285-(Ewrongx*275); break; case 5: y1 = 285-(Fwrongx*275); break; } Rectangle wrong = Rectangle(Point(x1,y1), Point(x2,285)); wrong.draw(MNGraph); } //Closing Text Ctitle2 = Text(Point(25, 380), "[Please click anywhere on this window to exit. Please do NOT click on the top left X button.]"); Ctitle2.setTextColor("Maroon"); Ctitle2.setStyle("Bold"); Ctitle2.setSize(13); Ctitle2.draw(MNGraph); MNGraph.getMouse(); }

The University of Southern California does not screen or control the content on this website and thus does not guarantee the accuracy, integrity, or quality of such content. All content on this website is provided by and is the sole responsibility of the person from which such content originated, and such content does not necessarily reflect the opinions of the University administration or the Board of Trustees