proj 3 soln.cpp

proj 3 soln.cpp - / Project 3: Guitar Zero #include...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
Project 3: Guitar Zero #include <string> using namespace std; const char END_OF_BEAT = '/'; //************************************* // isSongWellFormed //************************************* bool isSongWellFormed(string song) { // An empty song is well-formed. if (song.size() == 0) return true; // A non-empty song must end with an end-of-beat marker. if (song.at(song.size()-1) != END_OF_BEAT) return false; // At this point, we know the song ends properly, so in the following // loop, we do not have to worry about, say, there not being a character // following a digit. // Each iteration of the loop recognizes one beat. size_t k = 0; while (k != song.size()) { // The beat may have no note. if (song.at(k) == END_OF_BEAT) { k++; continue; } // There might be a note that starts with a digit. if (isdigit(song.at(k))) { k++; // There might be a second digit. if (isdigit(song.at(k))) k++; } // Verify color letter. char color = tolower(song.at(k));
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/02/2011 for the course CS 31 taught by Professor Melkanoff during the Spring '00 term at UCLA.

Page1 / 4

proj 3 soln.cpp - / Project 3: Guitar Zero #include...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online