Reading Quiz Questions
These are the questions that will appear on the reading quizzes in week 7. Remember these quizzes take place at the start of class, and you get points for correctness, not just participation. These will be the exact questions we ask you. They will be multiple choice clicker questions, but we do not provide the answer choice here. If you can answer them without the answer choices, you'll have no problems answering them when you see the choices. These are not designed to be overly tricky.
Tuesday, Oct 13
1. Below is the code of the clip method and it’s description. If you call the method asking to start the clip at 1000 and end the clip at 22000, what is the value of lengthInSamples.
/**
* Method to create a new sound by copying just part of
* the current sound to a new sound
* @param start the index to start the copy at (inclusive)
* @param end the index to stop the copy at (inclusive)
* @return a new sound with just the samples from start to
* end in it
*/
public Sound clip(int start, int end)
{
int lengthInSamples;
//code to calculate lengthInSamples
Sound target = new Sound(lengthInSamples);
//rest of method
}
2.
/**Method to copy part of the passed source sound into this sound at the given start index
* @param source the source sound to copy from
* @param sourceStart the starting index to copy from in the source (the copy will include this)
* @param sourceStop the ending index (the copy won’t include this)
* @param targetStart the index to start copying into
public void splice (Sound source, int souceStart, int sourceStop, int targetStart)
{
//loop copying from source to target
for(int sourceIndex = sourceStart, targetIndex = targetStart;
sourceIndex < sourceStop && sourceIndex < this.getLength();
sourceIndex++, tagetIndex++)
{
this.setSampleValueAt(targetIndex, source.getSampleValueAt(sourceIndex));
}
}
There seems like one parameter might be missing. Why is there no parameter:
targetStop -- the index you want to stop copying into in the target sound?
3.
Below is the mirrorFrontToBack() method
/**
* Method to mirror a sound front to back
*/
public void mirrorFrontToBack()
{
int length = this.getLength();
int mirrorPoint = length / 2;
int value = 0;
for(int i = 0; i < mirrorPoint; i++)
{
value = this.getSampleValueAt(i);
this.setSampleValueAt(____________, value);
}
}
What should go in the blank to complete this method?
/**
* Method to create a new sound by copying just part of
* the current sound to a new sound
* @param start the index to start the copy at (inclusive)
* @param end the index to stop the copy at (inclusive)
* @return a new sound with just the samples from start to
* end in it
*/
public Sound clip(int start, int end)
{
int lengthInSamples;
//code to calculate lengthInSamples
Sound target = new Sound(lengthInSamples);
//rest of method
}
2.
/**Method to copy part of the passed source sound into this sound at the given start index
* @param source the source sound to copy from
* @param sourceStart the starting index to copy from in the source (the copy will include this)
* @param sourceStop the ending index (the copy won’t include this)
* @param targetStart the index to start copying into
public void splice (Sound source, int souceStart, int sourceStop, int targetStart)
{
//loop copying from source to target
for(int sourceIndex = sourceStart, targetIndex = targetStart;
sourceIndex < sourceStop && sourceIndex < this.getLength();
sourceIndex++, tagetIndex++)
{
this.setSampleValueAt(targetIndex, source.getSampleValueAt(sourceIndex));
}
}
There seems like one parameter might be missing. Why is there no parameter:
targetStop -- the index you want to stop copying into in the target sound?
3.
Below is the mirrorFrontToBack() method
/**
* Method to mirror a sound front to back
*/
public void mirrorFrontToBack()
{
int length = this.getLength();
int mirrorPoint = length / 2;
int value = 0;
for(int i = 0; i < mirrorPoint; i++)
{
value = this.getSampleValueAt(i);
this.setSampleValueAt(____________, value);
}
}
What should go in the blank to complete this method?
Thursday, Nov 15
In class quiz