Programming Assignment Checklist: Plucking a Guitar String

Pair programming. On this assignment, you are encouraged (not required) to work with a partner provided you practice pair programming. Pair programming "is a practice in which two programmers work side-by-side at one computer, continuously collaborating on the same design, algorithm, code, or test." One partner is driving (designing and typing the code) while the other is navigating (reviewing the work, identifying bugs, and asking questions). The two partners switch roles every 30-40 minutes, and on demand, brainstorm.

Before pair programming, you must read the article All I really need to know about pair programming I learned in kindergarten. Your partner must be from the same precept. Only one member of the parternship will turn in the assignment and readme.txt; both partners will receive the same grade.

Please note that writing code with a partner without following the pair programming instructions listed above is a serious violation of the course collaboration policy.

Frequently Asked Questions

What are the goals of this assignment? To learn how to create user-defined data types in Java and to learn about digital audio.

Do I need to follow the prescribed API? Yes, we will be testing the methods in the API directly. If your method has a different signature or does not behave as specified, you will lose a substantial number of points. You may not add public methods to the API; however, you may add private methods (which are only accessible in the class in which they are declared).

Where do I enter keystrokes in GuitarHeroLite and GuitarHero? Be sure that the standard draw window has focus by clicking in it. Then, type the keystrokes.

How do I determine how many elements are in an array? If you're asking this, you probably need to review Section 1.4.

Is the size of a RingBuffer equal to the number of nonzeros? No. Some of the elements in the buffer can be zero. To get an accurate count, increment the instance variable size each time you call enqueue() and decrement it each time you call dequeue().

What should RingBuffer do if the client attempts to dequeue() from an empty buffer or enqueue() into a full buffer? We recommend throwing an exception to indicate the error. As an example, see Vector.java.

How do I round a double to the nearest int? See the toGray() method in Luminance.java (Program 3.1.3).

What happens if I send a sample whose value is greater than 1 or less than -1 to StdAudio? The value is clipped - it is replaced by the value 1.0 or -1.0, respectively.

I get an ArrayOutOfBounds or NullPointerException error in RingBuffer. What could cause this? Does your constructor correctly initialize all of the instance variables (first, last, size, and a[])? Did you allocate memory for your array with new? Did you inadvertently redeclare int first or double[] a in a method or constructor, thereby shadowing the instance variable with the same name?

I get a Ring buffer underflow error in GuitarHeroLite before I type any keystrokes. Why? Did you forget to initialize the ring buffer to contain N zeros in your GuitarString constructor?

When I run GuitarHeroLite for the first time, I hear no sound. What am I doing wrong? Make sure you have tested with the main() provided for GuitarString. If that works, it is likely something wrong with pluck() since the main() provided for GuitarString does not test that method. To diagnose the problem, print out the values of sample() and check that they become nonzero after you type lower case characters 'a' and 'c'.

When I run GuitarHeroLite, I hear static (either just one click, and then silence or continual static). What am I doing wrong? It's likely that pluck() is working, but tic() is not. The best test is to run the main() provided for GuitarString.

How do I use keyboard.indexOf(key)? If keyboard is a String and key is a character, then keyboard.indexOf(key) return the integer index of the first occurrence of the character key in the string keyboard (or -1 if it does not occur).

Testing

Be sure to thoroughly test each piece of your code as you write it. We offer some suggestions below.

Possible Progress Steps

These are purely suggestions for how you might make progress. You do not have to follow these steps.

Enrichment


COS 126 Home Page
wayne@cs.princeton.edu