1 / 20

Creative Commons Attribution Non-Commercial Share Alike License

Creative Commons Attribution Non-Commercial Share Alike License. http://creativecommons.org/licenses/by-nc-sa/3.0/ Original Developer: Beth Simon, 2009 bsimon@cs.ucsd.edu. CSE8A Lecture 19 (18 was midterm). Read next class: read up to page 287 Freshman seminar:

mahsa
Download Presentation

Creative Commons Attribution Non-Commercial Share Alike License

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Creative Commons AttributionNon-Commercial Share Alike License • http://creativecommons.org/licenses/by-nc-sa/3.0/ • Original Developer: Beth Simon, 2009bsimon@cs.ucsd.edu

  2. CSE8A Lecture 19 (18 was midterm) • Read next class: read up to page 287 • 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!

  3. Question 9: Did you read the part in red? 9. (3pts) Consider six variables, declared as follows:int a, b, c;   int i, j, k;The purpose of the following three lines of code is to swap thevalues in variables a and b:       c = a;       a = b;       b = c;In one sentence, written in the box below, state the purpose of the following three lines of code: // THERE WAS THREE LINES OF // CODE // HERE • Yes • No • No, I was too pressed for time • I don’t recall

  4. Feedback from midterm survey • I was a bit surprised by the cross problem but it was a good way to test understanding of a concept in a way that we hadn't looked at a million times before. • Was a good exam, I was a little freaked out after looking at the review midterms you posted online but this one seemed to be a lot easier. • The group exam helped me see other ways to write code on the flower • I liked how it was a reflection of most of the problems we seen in class and not something surprising. • too easy • I liked the second question on the exam that had us explain how we reasoned out our solution. I think that will be very beneficial to improving our class.

  5. Some good advice from your peers • I feel that I could've received a much better grade on the midterm, had I studied actual code more. • It had some tricky problems that really made me think. • I like how most of the questions were similar to the clicker questions that we did during lecture.

  6. Things I’ll fix from your help • Make it clear that input is in black and white • Group part shorter • More space for code (it was a hint, but OK) • More explanation on code writing question FYI • There is partial credit on MCQ • Time is always tough

  7. Be proud of yourself! •  I felt like skipping when I got out of the classroom because I was so happy. Studying was definitely worth it.

  8. By the end of today’s class you should be able to… • LG37: Identify, compare and contrast if-else if –else statements and separate if statement blocks. • LG38: Explain the relationship between amplitude, frequency, compression and rarefaction as it describes sound. • LG39: Defend a choice of sampling rate and sample size for a digital sound file based on human hearing abilities and translate that into an estimate of the size of a sampling array for storing sound. • LG40: Compare an array of Pixels which forms a Picture to an Array of SoundSamples which forms a Sound including the result of indexing into each. • LG41: Read, trace, and write code to change the volume of a Sound object (using for each, while and for loops)

  9. Advice: How to use if statements • Figure out what you want to do • Sketch out on paper your scenario. • Are your conditions for change mutually exclusive (only one can happen?) • If so, use an if, else if, (and maybe an else) • Does something ALWAYS get done? Use an else. • If more than one “thing” gets done – then probably this is in a separate if statement • Conditional change not related to each other should be in separate (multiple) if statements.

  10. Lab (Quiz) Review: Write if statement to make sure we have no index out of bounds errors for (int x = 0; x < this.getWidth(); x++) { for (int y = 0; y < this.getHeight(); y++) { <<INSERT LINE HERE>> int foo = this.getPixel(x-3, y-2).getRed() + this.getPixel(x+2,y+3).getRed(); } } if ( (x < this.getWidth() + 2) && (x >= -3) && (y < this.getHeigth() + 3) && (y >= -2) ) if ( (x < this.getWidth() - 2) && (x >= 3) && (y < this.getHeight() - 3) && (y >= 2) ) if ( (x+2 < this.getWidth() ) && (x-3 >= 0) && (y+3 < this.getHeight() ) && (y-2 >= 0) ) if ( (x+2 <= this.getWidth() ) && (x-3 > 0) && (y+3 <= this.getHeight() ) && (y-2 > 0) )

  11. Lab (Quiz) Review: Write if statement to make sure we have no index out of bounds errors for (int x = 0; x < this.getWidth(); x++) { for (int y = 0; y < this.getHeight(); y++) { int foo = this.getPixel(x-3, y-2).getRed() + this.getPixel(x+2,y+3).getRed(); } }

  12. Isomorphic Don’t show results until after next one Which of these statements best characterizes sepia? • All Color components are changed, based on that same component’s original value (red changed based on red, blue changed based on blue, green changed based on green) • All Color components are changed, based on one component’s original value (just use one component to make decision) • Some (not all) Color components are changed, based on their original value • Some (not all) Color components are changed based on red’s original component value • None of these are true!

  13. Which of these statements best characterizes posterize? • All Color components are changed, based on that same component’s original value (red changed based on red, blue changed based on blue, green changed based on green) • All Color components are changed, based on one component’s original value (just use one component to make decision) • Some (not all) Color components are changed, based on their original value • Some (not all) Color components are changed based on red’s original component value • None of these are true!

  14. Chapter 8: Sound!

  15. If the following sound were modified to be louder it would • Have shorter frequency and stronger compressions/rarefactions • Have smaller amplitude and stronger compressions/rarefactions • Have higher frequency and stronger compressions/rarefactions • Have larger amplitude and stronger compressions/rarefactions • None of the above

  16. If higher pitch? Show web site: compression rarefaction explanation

  17. Sample Rate versus Sample Size • Size is max (and min) amplitude • Rate is “how often we record an amplitude”

  18. Discuss: (3 min) Beth makes bad music: What’s wrong with these decisions? • I’ve decided that I don’t like the sampling rate and sample size provided by the book authors. Comment on my decision to use…

  19. Match the Java type to the (simplified) diagram • This is something you look at Picture Sound Pixel SoundSample Pixel[] SoundSample[] • This is something you listen to There are a few details hiding here – like Picture has a few more things in it.. Later…

  20. Our Representation of Sound String fileName = FileChooser.pickAFile(); Sound noise = new Sound(fileName); SoundSample[] noiseArray = noise.getSamples(); noiseArray[3].setValue(0); int foo = noiseArray[2].getValue(); String fileName = FileChooser.pickAFile(); Picture pic = new Picture(fileName); Pixel[] pixArray = pic.getPixels(); pixArray[3].setBlue(255); int foo = pixArray[2].getRed();

More Related