creative commons attribution non-commercial share alike license sa/3.0

14
Creative Commons Attribution Non-Commercial Share Alike License http://creativecommons.org/license s/by-nc-sa/3.0/ • Original Developer: Beth Simon, 2009 [email protected]

Upload: isabella-mitchell

Post on 06-Jan-2018

219 views

Category:

Documents


5 download

DESCRIPTION

Midterm: Avg 83% min 55% on individual final Answers posted on line tomorrow Midterms available for pickup Thurs/Fri in lab hours and in class

TRANSCRIPT

Page 1: Creative Commons Attribution Non-Commercial Share Alike License  sa/3.0

Creative Commons AttributionNon-Commercial Share Alike

License• http://creativecommons.org/licenses/by-nc-sa/3.0/

• Original Developer: Beth Simon, [email protected]

Page 2: Creative Commons Attribution Non-Commercial Share Alike License  sa/3.0

CSE8A Lecture 20• Read next class: read pg 293-300• Freshman seminar:

– Peer Instruction: Exploring a Revolution in College Science Teaching

– Find out more about the theory behind clicker use– Analyze data from this and previous classes!

• CSE 8A Art Show! Sat Nov 14 10:30-12 noon– Submit either your collage or chromakey (one per pair)– Art show open to all UCSD students – JSOE High School Outreach Day -- >110 high schoolers

(and their parents)– We want MORE, GREAT people in CSE at UCSD!

Page 3: Creative Commons Attribution Non-Commercial Share Alike License  sa/3.0

Midterm: Avg 83%90-80-70-60

min 55% on individual final

•Answers posted on line tomorrow•Midterms available for pickup Thurs/Fri in lab hours and in class

Page 4: Creative Commons Attribution Non-Commercial Share Alike License  sa/3.0

By the end of today’s class you should be able to…

• LG41: Read, trace, and write code to change the volume of a Sound object (using for each, while and for loops)

• LG42: Compare and contrast the difference between changing the Color of Pixels in a Picture to changing the volume of SoundSamples in a Sound.

Page 5: Creative Commons Attribution Non-Commercial Share Alike License  sa/3.0

How would we fill in this SampleSound[]

Page 6: Creative Commons Attribution Non-Commercial Share Alike License  sa/3.0

The Sample Rate that the Sound class ASSUMES is 22KHz:

How long is a SampleSound[] in a Sound object of 1 second?

A. 22 elementsB. 11,000 elementsC. 22,000 elementsD. 44,000 elementsE. We can’t tell from the data provided

Page 7: Creative Commons Attribution Non-Commercial Share Alike License  sa/3.0
Page 8: Creative Commons Attribution Non-Commercial Share Alike License  sa/3.0
Page 9: Creative Commons Attribution Non-Commercial Share Alike License  sa/3.0

Write code which makes the following changes

• Here’s a Sound

String fileName = FileChooser.pickAFile();Sound noise = new Sound(fileName);SoundSample[] noiseArray = noise.getSamples();<<< PICK SOME CODE >>>

for (SoundSample sample: noiseArray){ int foo = sample.getValue(); sample.setValue(foo/2);}

for (int i = noiseArray.length/2; i < noiseArray.length){ SoundSample sample = noiseArray[i]; int foo = sample.getValue(); sample.setValue(foo/2);}

int i = 0;while (i < noiseArray.length){ SoundSample sample = noiseArray[i]; int foo = sample.getValue(); sample.setValue(foo/2);}

Page 10: Creative Commons Attribution Non-Commercial Share Alike License  sa/3.0

What does that code do?• But before we do that…

Page 11: Creative Commons Attribution Non-Commercial Share Alike License  sa/3.0

So modified from the midterm:

A. This code modifies the middle half (from the top and bottom) of the picture

B. This code modifies the middle half (from the left and right) of the picture

C. This code loops over the pixels in the Pixel array starting at length/4 and up to 2*length/4 and gets the red, blue and green values adds them up and divides by 3 and sets that pixel to the calculated value

0: Pixel[] pixelArray = this.getPixels();1: int mystery;2: for(int i = pixelArray.length/4; i < 3*pixelArray.length/4; i++)3: {4: mystery = (pixelArray[i].getBlue() + pixelArray[i].getGreen() +

pixelArray[i].getRed() ) / 3;5: Color thing = new Color(mystery, mystery, mystery);6: pixelArray[i].setColor(thing);7: }8:

Page 12: Creative Commons Attribution Non-Commercial Share Alike License  sa/3.0

Questions of the form:What does this code do

should have what kind of answer?A. A short sentence your grandmother can

understandB. A short sentence that describes the loop

structure usedC. A short sentence that describes both the

loop structure used and the method calls executed inside the loop

D. A paragraph at least 50 words long that the causes the graders’ eyes to glaze over

Page 13: Creative Commons Attribution Non-Commercial Share Alike License  sa/3.0

REVIEW: Looking at this code…• Here’s a Sound

String fileName = FileChooser.pickAFile();Sound noise = new Sound(fileName);SoundSample[] noiseArray = noise.getSamples();<<< PICK SOME CODE >>>

for (SoundSample sample: noiseArray){ int foo = sample.getValue(); sample.setValue(foo/2);}

for (int i = noiseArray.length/2; i < noiseArray.length){ SoundSample sample = noiseArray[i]; int foo = sample.getValue(); sample.setValue(foo/2);}

int i = 0;while (i < noiseArray.length){ SoundSample sample = noiseArray[i]; int foo = sample.getValue(); sample.setValue(foo/2);}

Page 14: Creative Commons Attribution Non-Commercial Share Alike License  sa/3.0

What does that code doA. Makes a lower pitched sound during first half of

playB. Makes a quieter sound during first half of playC. Makes a lower pitched sound during second half

of playD. Makes a quieter sound during second half of

playE. For each SoundSample element if the array it

gets the Value and stores that in an int and then sets the Value with something that is half that