Sunteți pe pagina 1din 10

A file named report.doc or report.docx (in Microsoft Word format) or report.

txt (an ordinary text file) that contains: a. A brief description of notable obstacles you overcame. b. A description of the design of your program. You should use pseudocode in this description where it clarifies the presentation. c. A list of the test data that could be used to thoroughly test your program along with the reason for each test. You must note which test cases your program does not handle correctly. (!his could happen if you didn"t have time to write a complete solution or if you ran out of time while still debugging a supposedly complete solution.)

a. !he biggest obstacle # faced was creating a dynamically$si%ed array in order to contain the beats. While it would also have wor&ed if # created an array containing a large number of elements (i.e. string beats'(((()*) this code wastes memory by not using all the elements declared and would cause a runtime error if you had more beats than the array could hold. Another ma+or obstacle # encountered was an off by one runtime error associated with substrings: # made the common mista&e of forgetting that the first character of a string is the ,-th, character and the last character in a string is e.ual to the si%e of the string minus /. #nstead # treated the first character as the 0/st1 character and the last character in the string as the 0nth1 character where n is the si%e of the string. When this happened the 2tring.substr(int pos int n)* function threw an out of range exception when pos was past the end of the string. !he final obstacle # encountered was using string.append(01 3 char)* in order to append a character to the end of string which created some very strange runtime errors. After extensive testing # replaced all calls to append a character with string.append(int char)*.

b. 4escription of design: 4esign for bool is2ongWell5ormed(string song) 6 $7eturn true if song is a null string. $7eturn false if song does not end in a forward slash. $8onvert song into an array of beats. 7epeatedly for every beat: $8hec& if the last character of the beat is a slash $8hec& if the second to last character of the beat (if it exists) is a valid letter $8hec& if the third to last character of the beat (if it exists) is a digit $8hec& if the fourth to last character of the beat (if it exists) is a digit #f any of these chec&s turn out to be false return false. 9therwise if all of these chec&s turn out to be true return true. : 4esign for int translate2ong(string song 6 $#f song is a null string
string; instructions int; bad<eat)

set instructions to a null string and return -.

=rocedure to chec& if song is translatable: $#f song is not well formed return /. 7epeatedly for every beat: $#f a beat is not a sustained note go on to the next beat.

$5ind the length of the sustained note from the beat. $#f the note has a length of - or / set bad<eat to the current beat and return >. $#f the note has a length that is greater than the number of beats left in the song set bad<eat to one more than the number of beats and return ?. $9therwise chec& every beat that is supposed to be occupied by the sustained note. #f any do not only consist of a slash set bad<eat to the first bad beat and return @. $#f every beat occupied by the sustained note consists of only a slash then move on the next beat not occupied by the sustain.

#f the program iterates through every beat without finding a problem song is translatable. =rocedure to translate song:

then the

7epeatedly for every beat: $#f a beat only contains a slash append 0x1 to the end of instructions. $#f a beat consists of a color and a slash convert the color to lowercase and append it to the end of instructions. $#f a beat consists of one or two digits a color and a slash then convert the color to uppercase and append it n times to the end of instructions where n is the numerical value represented by the digits. !hen : s&ip the next (n$/) beats. return -.

After every beat has been iterated through

c. !est 4ata:

!est string: 01 0CD1 0rDDYD?gDDDoD1 0-?yDDD/-rDDDDDDDDDD1 0DDD1


0rDDgD1

0r1

0--?yDDD1

0yyDD1

0-y?DDD1

0DD-?DDDD1

0EyDDDrDDDD1

0DD-?<DDbD1

0@-gDDDDDyD1

0ErDDDD1

0DD/yDD1

0-rDD1

0?rDDyD-bDD@oD1

Axpected 7esult: #nstructions B 01* bad<eat B unchanged* return value B -* #nstructions B g* bad<eat B unchanged* return value B -* #nstructions B rxyCCCo* bad<eat B unchanged* return value B -* #nstructions B YYY7777777777* bad<eat B unchanged* return value B -* #nstructions B xxx* bad<eat B unchanged* return value B -* #nstructions B rxg* bad<eat B unchanged* return value B -* #nstructions B unchanged* bad<eat B unchanged* return value B /* #nstructions B unchanged* bad<eat B unchanged* return value B /* #nstructions B unchanged* bad<eat B unchanged* return value B /* #nstructions B unchanged* bad<eat B unchanged* return value B /* #nstructions B unchanged* bad<eat B unchanged* return value B /* #nstructions B unchanged* bad<eat B >* return value B @* #nstructions B unchanged* bad<eat B E* return value B @* #nstructions B unchanged* bad<eat B F* return value B ?* #nstructions B unchanged* bad<eat B E* return value B ?* #nstructions B unchanged* bad<eat B ?* return value B >* #nstructions B unchanged* bad<eat B /* return value B >* #nstructions B unchanged* bad<eat B ?* return value B @*

# fed all of these test strings into a string array and used a for loop to iterate through the array testing each of these cases. #f you would li&e the code for this is in the main method of the guitar.cpp file. Avery test case performed as expected and # am pretty sure # exhausted every case.

As for the reason why # chose these test cases !he first G test cases test well formed translatable songs.

!he next E cases test songs that are not well formed. !he next @ cases test songs that have normal notes during a sustain. !he next @ cases test songs that end prematurely. !he next @ cases test songs that contain sustains of length - or /. !he last case is a case # found in the =ro+ect ? spec my program output matches the spec. =rogram 9utput: in order to determine if

instructions: bad<eat : (((

7eturn Halue: -

instructions: g bad<eat : (((

7eturn Halue: -

instructions: rxyCCCo bad<eat : (((

7eturn Halue: -

instructions: YYY7777777777 bad<eat : (((

7eturn Halue: -

instructions: xxx bad<eat : (((

7eturn Halue: -

instructions: rxg bad<eat : (((

7eturn Halue: -

instructions: bad<eat : (((

7eturn Halue: /

instructions: bad<eat : (((

7eturn Halue: /

instructions: bad<eat : (((

7eturn Halue: /

instructions: bad<eat : (((

7eturn Halue: /

instructions: bad<eat : (((

7eturn Halue: /

instructions: bad<eat : >

7eturn Halue: @

instructions: bad<eat : E

7eturn Halue: @

instructions: bad<eat : F

7eturn Halue: ?

instructions: bad<eat : E

7eturn Halue: ?

instructions: bad<eat : ?

7eturn Halue: >

instructions: bad<eat : /

7eturn Halue: >

instructions: bad<eat : ?

7eturn Halue: @

=ress any &ey to continue . . .

S-ar putea să vă placă și